Hotfix delete file

This commit is contained in:
Vincent Alamelle 2023-05-10 14:53:56 +02:00
parent 08f2b0ea02
commit cf11c386f7

View File

@ -48,12 +48,15 @@ export default class FilesService extends BaseService {
* @throws {Error} If file cannot be deleted
*/
public async delete(uid: string) {
const fileToUnpin = await this.filesRepository.findOneByUid(uid);
if(fileToUnpin){
try {
const fileToUnpin = await this.filesRepository.findOneByUid(uid);
const decryptedFilePath = await this.cryptoService.decrypt(fileToUnpin.file_path, fileToUnpin.iv);
const fileHash= decryptedFilePath.substring(this.variables.PINATA_GATEWAY.length);
await this.ipfsService.unpinFile(fileHash)
} catch (error) {
console.log(error);
}
return this.filesRepository.delete(uid);
}