Hotfix delete file
This commit is contained in:
parent
08f2b0ea02
commit
cf11c386f7
@ -48,12 +48,15 @@ export default class FilesService extends BaseService {
|
|||||||
* @throws {Error} If file cannot be deleted
|
* @throws {Error} If file cannot be deleted
|
||||||
*/
|
*/
|
||||||
public async delete(uid: string) {
|
public async delete(uid: string) {
|
||||||
const fileToUnpin = await this.filesRepository.findOneByUid(uid);
|
try {
|
||||||
if(fileToUnpin){
|
const fileToUnpin = await this.filesRepository.findOneByUid(uid);
|
||||||
const decryptedFilePath = await this.cryptoService.decrypt(fileToUnpin.file_path, fileToUnpin.iv);
|
const decryptedFilePath = await this.cryptoService.decrypt(fileToUnpin.file_path, fileToUnpin.iv);
|
||||||
const fileHash= decryptedFilePath.substring(this.variables.PINATA_GATEWAY.length);
|
const fileHash= decryptedFilePath.substring(this.variables.PINATA_GATEWAY.length);
|
||||||
await this.ipfsService.unpinFile(fileHash)
|
await this.ipfsService.unpinFile(fileHash)
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.filesRepository.delete(uid);
|
return this.filesRepository.delete(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user