Merge branch 'dev' of https://github.com/smart-chain-fr/leCoffre into dev
This commit is contained in:
commit
f8bc06bb8b
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user