From 424c11796399a5c223a403968f253aa4f13afd56 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 21 Jun 2021 15:06:05 +0200 Subject: [PATCH] MOBILE-3320 files: Fix clearTmpFiles deleting files that shouldn't be --- src/core/features/fileuploader/services/fileuploader.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/features/fileuploader/services/fileuploader.ts b/src/core/features/fileuploader/services/fileuploader.ts index c9546f807..cf17de72b 100644 --- a/src/core/features/fileuploader/services/fileuploader.ts +++ b/src/core/features/fileuploader/services/fileuploader.ts @@ -19,7 +19,7 @@ import { MediaFile, CaptureError, CaptureAudioOptions, CaptureVideoOptions } fro import { Subject } from 'rxjs'; import { CoreApp } from '@services/app'; -import { CoreFile } from '@services/file'; +import { CoreFile, CoreFileProvider } from '@services/file'; import { CoreFilepool } from '@services/filepool'; import { CoreSites } from '@services/sites'; import { CoreMimetypeUtils } from '@services/utils/mimetype'; @@ -191,14 +191,14 @@ export class CoreFileUploaderProvider { /** * Clear temporary attachments to be uploaded. - * Attachments already saved in an offline store will NOT be deleted. + * Attachments already saved in an offline store will NOT be deleted, only files in tmp folder will be deleted. * * @param files List of files. */ clearTmpFiles(files: (CoreWSFile | FileEntry)[]): void { - // Delete the local files. + // Delete the temporary files. files.forEach((file) => { - if ('remove' in file) { + if ('remove' in file && CoreFile.removeBasePath(file.toURL()).startsWith(CoreFileProvider.TMPFOLDER)) { // Pass an empty function to prevent missing parameter error. file.remove(() => { // Nothing to do.