Skip to content

Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.

feat(files): make downloads and (de)compression abortable

johavena43025eaa997
diff --git a/backend/src/applications/files/constants/cache.ts b/backend/src/applications/files/constants/cache.ts
index 86738ec7..714b792e 100644
--- a/backend/src/applications/files/constants/cache.ts
+++ b/backend/src/applications/files/constants/cache.ts
@@ -1,5 +1,7 @@
// cache task key = `ftask-$(userId}-${taskId}` => FileTask
export const CACHE_TASK_PREFIX = 'ftask' as const
+// cache task cancellation key = `ftask-cancel-$(userId}-${taskId}` => boolean
+export const CACHE_TASK_CANCEL_PREFIX = `${CACHE_TASK_PREFIX}-cancel` as const
export const CACHE_TASK_TTL = 86400 as const // one day
// cache token key = `flock|token?:${uuid}|path:${path}|ownerId?:${number}|spaceId?:${number}|...props` => FileLock
export const CACHE_LOCK_PREFIX = 'flock' as const
diff --git a/backend/src/applications/files/constants/routes.ts b/backend/src/applications/files/constants/routes.ts
index c5e58105..965ba6f2 100644
--- a/backend/src/applications/files/constants/routes.ts
+++ b/backend/src/applications/files/constants/routes.ts
@@ -6,6 +6,7 @@ export const FILES_ROUTE = {
OPERATION: 'operation',
TASK_OPERATION: 'task/operation',
TASKS: 'tasks',
+ TASKS_CANCEL: 'cancel',
TASKS_DOWNLOAD: 'download',
RECENTS: 'recents',
SEARCH: 'search',
@@ -23,6 +24,7 @@ export const API_FILES_TASK_OPERATION_DOWNLOAD = `${API_FILES_TASK_OPERATION}/${
export const API_FILES_TASK_OPERATION_COMPRESS = `${API_FILES_TASK_OPERATION}/${FILE_OPERATION.COMPRESS}`
export const API_FILES_TASK_OPERATION_DECOMPRESS = `${API_FILES_TASK_OPERATION}/${FILE_OPERATION.DECOMPRESS}`
export const API_FILES_TASKS = `${FILES_ROUTE.BASE}/${FILES_ROUTE.TASKS}`
+export const API_FILES_TASKS_CANCEL = `${API_FILES_TASKS}/${FILES_ROUTE.TASKS_CANCEL}`
export const API_FILES_TASKS_DOWNLOAD = `${FILES_ROUTE.BASE}/${FILES_ROUTE.TASKS}/${FILES_ROUTE.TASKS_DOWNLOAD}`
export const API_FILES_RECENTS = `${FILES_ROUTE.BASE}/${FILES_ROUTE.RECENTS}`
export const API_FILES_SEARCH = `${FILES_ROUTE.BASE}/${FILES_ROUTE.SEARCH}`
diff --git a/backend/src/applications/files/files-tasks.controller.ts b/backend/src/applications/files/files-tasks.controller.ts
index 4190946d..b67d5fd6 100644
--- a/backend/src/applications/files/files-tasks.controller.ts
+++ b/backend/src/applications/files/files-tasks.controller.ts
@@ -1,4 +1,4 @@
-import { Controller, Delete, Get, Param, Req, Res, StreamableFile } from '@nestjs/common'
+import { Controller, Delete, Get, Param, Post, Req, Res, StreamableFile } from '@nestjs/common'
import { FastifyReply } from 'fastify'
import { FastifySpaceRequest } from '../spaces/interfaces/space-request.interface'
import { GetUser } from '../users/decorators/user.decorator'
@@ -20,6 +20,11 @@ export class FilesTasksController {
return this.filesTasksManager.deleteTasks(user, taskId)
}
+ @Post(`${FILES_ROUTE.TASKS_CANCEL}/:id`)
+ cancelTask(@GetUser() user: UserModel, @Param('id') taskId: string) {
+ return this.filesTasksManager.cancelTask(user.id, taskId)
+ }
+
@Get(`${FILES_ROUTE.TASKS_DOWNLOAD}/:id`)
downloadTaskFile(
@GetUser() user: UserModel,
diff --git a/backend/src/applications/files/interfaces/download-file.interface.ts b/backend/src/applications/files/interfaces/download-file.interface.ts
index 66450bf5..acd0e0c4 100644
--- a/backend/src/applications/files/interfaces/download-file.interface.ts
+++ b/backend/src/applications/files/interfaces/download-file.interface.ts
@@ -12,4 +12,5 @@ export interface DownloadFileOptions {
publishedPath?: string
getContentInfo?: boolean
maxSize?: number
+ signal?: AbortSignal
}
diff --git a/backend/src/applications/files/models/file-task.ts b/backend/src/applications/files/models/file-task.ts
index 96b90db7..809396c9 100644
--- a/backend/src/applications/files/models/file-task.ts
+++ b/backend/src/applications/files/models/file-task.ts
@@ -3,7 +3,8 @@ import { FILE_OPERATION } from '../constants/operations'
export enum FileTaskStatus {
PENDING,
SUCCESS,
- ERROR
+ ERROR,
+ CANCELLED
}
export interface FileTaskProps {
diff --git a/backend/src/applications/files/services/files-manager.service.spec.ts b/backend/src/applications/files/services/files-manager.service.spec.ts
index 5160de10..7d18ad46 100644
--- a/backend/src/applications/files/services/files-manager.service.spec.ts
+++ b/backend/src/applications/files/services/files-manager.service.spec.ts
@@ -1155,7 +1155,7 @@ describe(FilesManager.name, () => {
await service.decompress(user, space)
expect(filesUtils.makeTempDir).toHaveBeenCalledWith('/data/users/john/tmp', 'archive-extract-')
- expect(unzipSpy).toHaveBeenCalledWith('/data/users/john/files/archive.zip', '/data/users/john/tmp/archive-extract-123', undefined)
+ expect(unzipSpy).toHaveBeenCalledWith('/data/users/john/files/archive.zip', '/data/users/john/tmp/archive-extract-123', undefined, undefined)
expect(filesUtils.moveFiles).toHaveBeenCalledWith('/data/users/john/tmp/archive-extract-123', '/data/users/john/files/archive')
expect(taskEmitSpy).toHaveBeenCalledWith(
'startWatch',
@@ -1176,7 +1176,13 @@ describe(FilesManager.name, () => {
await service.decompress(user, space)
- expect(untarSpy).toHaveBeenCalledWith('/data/users/john/files/archive.tar.gz', '/data/users/john/tmp/archive-extract-123', true, undefined)
+ expect(untarSpy).toHaveBeenCalledWith(
+ '/data/users/john/files/archive.tar.gz',
+ '/data/users/john/tmp/archive-extract-123',
+ true,
+ undefined,
+ undefined
+ )
expect(filesUtils.moveFiles).toHaveBeenCalledWith('/data/users/john/tmp/archive-extract-123', '/data/users/john/files/archive')
})
@@ -1189,7 +1195,7 @@ describe(FilesManager.name, () => {
await service.decompress(user, space)
- expect(unzipSpy).toHaveBeenCalledWith('/data/users/john/files/archive.zip', '/data/users/john/tmp/archive-extract-123', 60)
+ expect(unzipSpy).toHaveBeenCalledWith('/data/users/john/files/archive.zip', '/data/users/john/tmp/archive-extract-123', 60, undefined)
})
it('should remove partial extraction and skip add event on failure', async () => {
diff --git a/backend/src/applications/files/services/files-manager.service.ts b/backend/src/applications/files/services/files-manager.service.ts
index 9d72df2f..9ef0fb85 100644
--- a/backend/src/applications/files/services/files-manager.service.ts
+++ b/backend/src/applications/files/services/files-manager.service.ts
@@ -567,7 +567,7 @@ export class FilesManager {
await this.filesQueries.deleteFiles(space.dbFile, isDir, forceDeleteInDB)
}
- async downloadFromUrl(user: UserModel, space: SpaceEnv, downloadDto: DownloadFileDto): Promise<void> {
+ async downloadFromUrl(user: UserModel, space: SpaceEnv, downloadDto: DownloadFileDto, signal?: AbortSignal): Promise<void> {
this.checkNotTrashRepository(space)
this.logger.log({ tag: this.downloadFromUrl.name, msg: `${downloadDto.url}` })
const dstPath = await uniqueFilePathFromDir(space.realPath)
@@ -582,7 +582,8 @@ export class FilesManager {
}
try {
- await new DownloadFile(this.http).download(downloadDto, tmpPath, { space: space, publishedPath: dstPath })
+ await new DownloadFile(this.http).download(downloadDto, tmpPath, { space, publishedPath: dstPath, signal })
+ signal?.throwIfAborted()
await moveFiles(tmpPath, dstPath)
} catch (e) {
await removeFiles(tmpPath).catch((err: Error) =>
@@ -596,7 +597,7 @@ export class FilesManager {
FileEvent.emit('event', { user, space, action: ACTION.ADD, rPath: dstPath })
}
- async compress(user: UserModel, space: SpaceEnv, dto: CompressFileDto): Promise<void> {
+ async compress(user: UserModel, space: SpaceEnv, dto: CompressFileDto, signal?: AbortSignal): Promise<void> {
// This method is currently used only by files-methods.service, which handles input sanitization.
// If it is used in other services in the future, make sure to refactor accordingly to sanitize inputs properly.
if (dto.compressInDirectory) {
@@ -634,9 +635,10 @@ export class FilesManager {
let entriesPromise: Promise<void> | undefined
try {
const dstStream = fs.createWriteStream(tmpPath, { highWaterMark: DEFAULT_HIGH_WATER_MARK })
- pipePromise = pipeline(archive, dstStream) // handle archive errors + write stream
+ pipePromise = pipeline(archive, dstStream, { signal }) // handle archive errors + write stream
entriesPromise = (async () => {
for (const f of dto.files) {
+ signal?.throwIfAborted()
const isDir = await isPathIsDir(f.path)
if (aborted) return
if (isDir) {
@@ -651,6 +653,7 @@ export class FilesManager {
}
})()
await Promise.all([entriesPromise, pipePromise])
+ signal?.throwIfAborted()
await moveFiles(tmpPath, dstPath)
} catch (e) {
aborted = true
@@ -668,7 +671,7 @@ export class FilesManager {
FileEvent.emit('event', { user, space, action: ACTION.ADD, rPath: dstPath })
}
- async decompress(user: UserModel, space: SpaceEnv): Promise<void> {
+ async decompress(user: UserModel, space: SpaceEnv, signal?: AbortSignal): Promise<void> {
// checks
this.checkNotTrashRepository(space)
if (!(await isPathExists(space.realPath))) {
@@ -696,10 +699,11 @@ export class FilesManager {
// do
const maxExtractedSize = space.storageQuota === null ? undefined : Math.max(0, space.storageQuota - space.storageUsage)
if (extension === '.zip') {
- await extractZip(space.realPath, tmpPath, maxExtractedSize)
+ await extractZip(space.realPath, tmpPath, maxExtractedSize, signal)
} else {
- await extractTar(space.realPath, tmpPath, COMPRESSION_EXTENSION.get(extension) === TAR_GZ_EXTENSION, maxExtractedSize)
+ await extractTar(space.realPath, tmpPath, COMPRESSION_EXTENSION.get(extension) === TAR_GZ_EXTENSION, maxExtractedSize, signal)
}
+ signal?.throwIfAborted()
if (await isPathExists(dstPath)) {
throw new FileError(HttpStatus.CONFLICT, 'The destination already exists')
}
diff --git a/backend/src/applications/files/services/files-methods.service.ts b/backend/src/applications/files/services/files-methods.service.ts
index 876ef781..548f68f7 100644
--- a/backend/src/applications/files/services/files-methods.service.ts
+++ b/backend/src/applications/files/services/files-methods.service.ts
@@ -71,16 +71,16 @@ export class FilesMethods {
}
}
- async downloadFromUrl(user: UserModel, space: SpaceEnv, downloadDto: DownloadFileDto): Promise<void> {
+ async downloadFromUrl(user: UserModel, space: SpaceEnv, downloadDto: DownloadFileDto, signal?: AbortSignal): Promise<void> {
checkFileName(space.realPath)
try {
- return await this.filesManager.downloadFromUrl(user, space, downloadDto)
+ return await this.filesManager.downloadFromUrl(user, space, downloadDto, signal)
} catch (e) {
this.handleError(space, FILE_OPERATION.DOWNLOAD, e)
}
}
- async compress(user: UserModel, space: SpaceEnv, compressFileDto: CompressFileDto): Promise<void> {
+ async compress(user: UserModel, space: SpaceEnv, compressFileDto: CompressFileDto, signal?: AbortSignal): Promise<void> {
compressFileDto.name = checkFileName(space.realPath)
try {
for (const f of compressFileDto.files) {
@@ -107,15 +107,15 @@ export class FilesMethods {
return this.handleError(space, FILE_OPERATION.COMPRESS, new FileError(HttpStatus.NOT_FOUND, `${f.name} does not exist`))
}
}
- return await this.filesManager.compress(user, space, compressFileDto)
+ return await this.filesManager.compress(user, space, compressFileDto, signal)
} catch (e) {
this.handleError(space, FILE_OPERATION.COMPRESS, e)
}
}
- async decompress(user: UserModel, space: SpaceEnv): Promise<void> {
+ async decompress(user: UserModel, space: SpaceEnv, _dto?: null, signal?: AbortSignal): Promise<void> {
try {
- return await this.filesManager.decompress(user, space)
+ return await this.filesManager.decompress(user, space, signal)
} catch (e) {
this.handleError(space, FILE_OPERATION.DECOMPRESS, e)
}
diff --git a/backend/src/applications/files/services/files-scheduler.service.ts b/backend/src/applications/files/services/files-scheduler.service.ts
index b52647fe..acc93432 100644
--- a/backend/src/applications/files/services/files-scheduler.service.ts
+++ b/backend/src/applications/files/services/files-scheduler.service.ts
@@ -11,7 +11,7 @@ import { getTablesWithFileIdColumn } from '../../../infrastructure/database/util
import { USER_PATH, USER_ROLE } from '../../users/constants/user'
import { UserModel } from '../../users/models/user.model'
import { users } from '../../users/schemas/users.schema'
-import { CACHE_TASK_PREFIX } from '../constants/cache'
+import { CACHE_TASK_CANCEL_PREFIX, CACHE_TASK_PREFIX } from '../constants/cache'
import { FileTask, FileTaskStatus } from '../models/file-task'
import { filesRecents } from '../schemas/files-recents.schema'
import { files } from '../schemas/files.schema'
@@ -259,8 +259,14 @@ export class FilesScheduler {
private async cleanupInterruptedTasks(): Promise<void> {
try {
let nb = 0
+ let nbCancellationRequests = 0
const keys = await this.cache.keys(`${CACHE_TASK_PREFIX}-*`)
for (const key of keys) {
+ if (key.startsWith(`${CACHE_TASK_CANCEL_PREFIX}-`)) {
+ await this.cache.del(key)
+ nbCancellationRequests++
+ continue
+ }
const task = await this.cache.get(key)
if (task && task.status === FileTaskStatus.PENDING) {
task.status = FileTaskStatus.ERROR
@@ -269,7 +275,7 @@ export class FilesScheduler {
this.cache.set(key, task).catch((e: Error) => this.logger.error({ tag: this.cleanupInterruptedTasks.name, msg: `${e}` }))
}
}
- this.logger.log({ tag: this.cleanupInterruptedTasks.name, msg: `${nb} tasks cleaned` })
+ this.logger.log({ tag: this.cleanupInterruptedTasks.name, msg: `${nb} tasks cleaned, ${nbCancellationRequests} cancellation requests cleared` })
} catch (e) {
this.logger.error({ tag: this.cleanupInterruptedTasks.name, msg: `${e}` })
}
diff --git a/backend/src/applications/files/services/files-tasks-manager.service.spec.ts b/backend/src/applications/files/services/files-tasks-manager.service.spec.ts
index f35bb4e1..6d848832 100644
--- a/backend/src/applications/files/services/files-tasks-manager.service.spec.ts
+++ b/backend/src/applications/files/services/files-tasks-manager.service.spec.ts
@@ -6,7 +6,7 @@ import * as filesUtils from '../utils/files'
import { FileTaskEvent } from '../events/file-events'
import { SendFile } from '../utils/send-file'
import { FILE_OPERATION } from '../constants/operations'
-import { CACHE_TASK_PREFIX, CACHE_TASK_TTL } from '../constants/cache'
+import { CACHE_TASK_CANCEL_PREFIX, CACHE_TASK_PREFIX, CACHE_TASK_TTL } from '../constants/cache'
import { FileTaskStatus } from '../models/file-task'
import { FilesMethods } from './files-methods.service'
import { FilesTasksManager } from './files-tasks-manager.service'
@@ -96,6 +96,56 @@ describe(FilesTasksManager.name, () => {
it('should build task cache key with and without task id', () => {
expect(FilesTasksManager.getCacheKey(10, 'task-1')).toBe(`${CACHE_TASK_PREFIX}-10-task-1`)
expect(FilesTasksManager.getCacheKey(10)).toBe(`${CACHE_TASK_PREFIX}-10-*`)
+ expect(FilesTasksManager.getCancellationCacheKey(10, 'task-1')).toBe(`${CACHE_TASK_CANCEL_PREFIX}-10-task-1`)
+ })
+
+ it('should request cancellation through cache for a pending supported task', async () => {
+ cacheStore.set(`${CACHE_TASK_PREFIX}-15-task-1`, {
+ id: 'task-1',
+ type: FILE_OPERATION.DOWNLOAD,
+ status: FileTaskStatus.PENDING
+ })
+
+ await filesTasksManager.cancelTask(15, 'task-1')
+
+ expect(cache.set).toHaveBeenCalledWith(`${CACHE_TASK_CANCEL_PREFIX}-15-task-1`, true, CACHE_TASK_TTL)
+ })
+
+ it('should abort a cancellable task and store a cancelled status when cancellation is requested', async () => {
+ vi.useFakeTimers()
+ try {
+ const taskId = '33333333-3333-4333-8333-333333333333'
+ const user = { id: 7 } as any
+ const space = { url: 'files/personal/document.txt' } as any
+ const cacheKey = `${CACHE_TASK_PREFIX}-7-${taskId}`
+ const cancellationCacheKey = `${CACHE_TASK_CANCEL_PREFIX}-7-${taskId}`
+ let taskSignal!: AbortSignal
+
+ vi.spyOn(crypto, 'randomUUID').mockReturnValueOnce(taskId)
+ filesMethods.doWork.mockImplementationOnce((_user, _space, _dto, signal?: AbortSignal) => {
+ if (!signal) return Promise.reject(new Error('missing abort signal'))
+ taskSignal = signal
+ return new Promise((_resolve, reject) => {
+ signal.addEventListener('abort', () => reject(signal.reason), { once: true })
+ })
+ })
+
+ await filesTasksManager.createTask(FILE_OPERATION.DOWNLOAD, user, space, null, 'doWork')
+ cacheStore.set(cancellationCacheKey, true)
+
+ await vi.advanceTimersByTimeAsync(1000)
+ for (let i = 0; i < 6; i++) await Promise.resolve()
+
+ const storedTask = cacheStore.get(cacheKey)
+ expect(filesMethods.doWork).toHaveBeenCalledWith(user, space, null, expect.any(AbortSignal))
+ expect(taskSignal.aborted).toBe(true)
+ expect(storedTask.status).toBe(FileTaskStatus.CANCELLED)
+ expect(storedTask.result).toBe('Cancelled')
+ expect(cacheStore.has(cancellationCacheKey)).toBe(false)
+ expect((filesTasksManager as any).tasksCancellationWatcher).toEqual({})
+ } finally {
+ vi.useRealTimers()
+ }
})
it('should watch a temporary path while keeping the published file name', () => {
diff --git a/backend/src/applications/files/services/files-tasks-manager.service.ts b/backend/src/applications/files/services/files-tasks-manager.service.ts
index 2b35a8b4..c88e849c 100644
--- a/backend/src/applications/files/services/files-tasks-manager.service.ts
+++ b/backend/src/applications/files/services/files-tasks-manager.service.ts
@@ -7,7 +7,7 @@ import { currentTimeStamp } from '../../../common/shared'
import { Cache } from '../../../infrastructure/cache/cache.service'
import { SpaceEnv } from '../../spaces/models/space-env.model'
import { UserModel } from '../../users/models/user.model'
-import { CACHE_TASK_PREFIX, CACHE_TASK_TTL } from '../constants/cache'
+import { CACHE_TASK_CANCEL_PREFIX, CACHE_TASK_PREFIX, CACHE_TASK_TTL } from '../constants/cache'
import { FILE_OPERATION } from '../constants/operations'
import { FileTask, FileTaskProps, FileTaskStatus } from '../models/file-task'
import { countDirEntries, dirName, fileName, fileSize, isPathExists, isPathIsDir, removeFiles } from '../utils/files'
@@ -21,6 +21,7 @@ export class FilesTasksManager implements OnModuleDestroy {
private readonly logger = new Logger(FilesTasksManager.name)
private readonly watchInterval = 1000
private tasksWatcher: Record<string, NodeJS.Timeout> = {}
+ private tasksCancellationWatcher: Record<string, NodeJS.Timeout> = {}
constructor(
private readonly cache: Cache,
@@ -33,11 +34,18 @@ export class FilesTasksManager implements OnModuleDestroy {
return `${CACHE_TASK_PREFIX}-${userId}-${taskId || '*'}`
}
+ static getCancellationCacheKey(userId: number, taskId: string): string {
+ return `${CACHE_TASK_CANCEL_PREFIX}-${userId}-${taskId}`
+ }
+
onModuleDestroy(): void {
FileTaskEvent.off('startWatch', this.onStartWatch)
for (const cacheKey of Object.keys(this.tasksWatcher)) {
this.stopWatch(cacheKey)
}
+ for (const cacheKey of Object.keys(this.tasksCancellationWatcher)) {
+ this.stopCancellationWatch(cacheKey)
+ }
}
async createTask(type: FILE_OPERATION, user: UserModel, space: SpaceEnv, dto: any, method: string): Promise<FileTask> {
@@ -46,14 +54,20 @@ export class FilesTasksManager implements OnModuleDestroy {
const newTask = new FileTask(taskId, type, dirName(space.url), fileName(space.url))
await this.storeTask(cacheKey, newTask)
space.task = { cacheKey: cacheKey, props: {} }
- this.filesMethods[method](user, space, dto)
+ const controller = this.watchCancellation(type, user.id, taskId, cacheKey)
+ const taskPromise = controller ? this.filesMethods[method](user, space, dto, controller.signal) : this.filesMethods[method](user, space, dto)
+ taskPromise
.then((data: any) => {
this.logger.debug({ tag: this.createTask.name, msg: `${newTask.name} : ${method} done` })
this.setTaskDone(cacheKey, FileTaskStatus.SUCCESS, data).catch((e: Error) => this.logger.error({ tag: this.createTask.name, msg: `${e}` }))
})
.catch((e: HttpException | any) => {
this.logger.error({ tag: this.createTask.name, msg: `${newTask.name} : ${method} : ${e}` })
- this.setTaskDone(cacheKey, FileTaskStatus.ERROR, e.message).catch((e: Error) => this.logger.error({ tag: this.createTask.name, msg: `${e}` }))
+ this.setTaskDone(
+ cacheKey,
+ controller?.signal.aborted ? FileTaskStatus.CANCELLED : FileTaskStatus.ERROR,
+ controller?.signal.aborted ? 'Cancelled' : e.message
+ ).catch((e: Error) => this.logger.error({ tag: this.createTask.name, msg: `${e}` }))
})
return newTask
}
@@ -94,6 +108,21 @@ export class FilesTasksManager implements OnModuleDestroy {
}
}
+ async cancelTask(userId: number, taskId: string): Promise<void> {
+ const cacheKey = FilesTasksManager.getCacheKey(userId, taskId)
+ const task: FileTask = await this.cache.get(cacheKey)
+ if (!task) {
+ throw new HttpException('Task not found', HttpStatus.NOT_FOUND)
+ }
+ if (task.status !== FileTaskStatus.PENDING || !this.canCancel(task.type)) {
+ throw new HttpException('Not applicable', HttpStatus.BAD_REQUEST)
+ }
+ const isStored = await this.cache.set(FilesTasksManager.getCancellationCacheKey(userId, taskId), true, CACHE_TASK_TTL)
+ if (!isStored) {
+ throw new HttpException('Unable to cancel task', HttpStatus.INTERNAL_SERVER_ERROR)
+ }
+ }
+
async downloadArchive(user: UserModel, taskId: string, req: FastifyAuthenticatedRequest, res: FastifyReply): Promise<StreamableFile> {
const cacheKey = FilesTasksManager.getCacheKey(user.id, taskId)
const task: FileTask = await this.cache.get(cacheKey)
@@ -135,6 +164,10 @@ export class FilesTasksManager implements OnModuleDestroy {
await this.cache.set(cacheKey, task, CACHE_TASK_TTL)
}
this.stopWatch(cacheKey)
+ this.stopCancellationWatch(cacheKey)
+ await this.cache
+ .del(cacheKey.replace(`${CACHE_TASK_PREFIX}-`, `${CACHE_TASK_CANCEL_PREFIX}-`))
+ .catch((e: Error) => this.logger.error({ tag: this.setTaskDone.name, msg: `${e}` }))
}
private async updateTask(cacheKey: string, props?: FileTaskProps, task?: Partial<FileTask>): Promise<void> {
@@ -198,6 +231,37 @@ export class FilesTasksManager implements OnModuleDestroy {
this.tasksWatcher[cacheKey] = watcher
}
+ private watchCancellation(type: FILE_OPERATION, userId: number, taskId: string, cacheKey: string): AbortController | undefined {
+ if (!this.canCancel(type)) return
+ const controller = new AbortController()
+ const cancellationCacheKey = FilesTasksManager.getCancellationCacheKey(userId, taskId)
+ const watcher = setInterval(() => void this.abortTaskIfRequested(cacheKey, cancellationCacheKey, controller), this.watchInterval)
+ watcher.unref()
+ this.tasksCancellationWatcher[cacheKey] = watcher
+ return controller
+ }
+
+ private async abortTaskIfRequested(cacheKey: string, cancellationCacheKey: string, controller: AbortController): Promise<void> {
+ try {
+ if (!(await this.cache.get(cancellationCacheKey))) return
+ controller.abort(new Error('Cancelled'))
+ this.stopCancellationWatch(cacheKey)
+ await this.cache.del(cancellationCacheKey)
+ } catch (e) {
+ this.logger.error({ tag: this.abortTaskIfRequested.name, msg: `${e}` })
+ }
+ }
+
+ private stopCancellationWatch(cacheKey: string): void {
+ if (!(cacheKey in this.tasksCancellationWatcher)) return
+ clearInterval(this.tasksCancellationWatcher[cacheKey])
+ delete this.tasksCancellationWatcher[cacheKey]
+ }
+
+ private canCancel(type: FILE_OPERATION): boolean {
+ return type === FILE_OPERATION.DOWNLOAD || type === FILE_OPERATION.COMPRESS || type === FILE_OPERATION.DECOMPRESS
+ }
+
private async updateCompressTask(space: SpaceEnv, rPath: string, publishedPath?: string): Promise<void> {
try {
const size = await this.readWatchedPath(rPath, publishedPath, fileSize)
diff --git a/backend/src/applications/files/utils/download-file.ts b/backend/src/applications/files/utils/download-file.ts
index 3e2ba08e..5a2e53c2 100644
--- a/backend/src/applications/files/utils/download-file.ts
+++ b/backend/src/applications/files/utils/download-file.ts
@@ -37,19 +37,15 @@ export class DownloadFile {
async download(
downloadDto: DownloadFileDto,
dstPath: string,
- options: { allowPrivateIP?: boolean; space?: SpaceEnv; publishedPath?: string; getContentInfo: true; maxSize?: number }
+ options: DownloadFileOptions & { getContentInfo: true }
): Promise<DownloadFileContentInfo>
- async download(
- downloadDto: DownloadFileDto,
- dstPath: string,
- options?: { allowPrivateIP?: boolean; space?: SpaceEnv; publishedPath?: string; getContentInfo?: false | undefined; maxSize?: number }
- ): Promise<void>
+ async download(downloadDto: DownloadFileDto, dstPath: string, options?: DownloadFileOptions & { getContentInfo?: false | undefined }): Promise<void>
async download(downloadDto: DownloadFileDto, dstPath: string, options?: DownloadFileOptions): Promise<void | DownloadFileContentInfo> {
const identityEncodingConfig = { decompress: false, headers: { 'Accept-Encoding': 'identity' } }
const { response: headRes, url } = await this.request(
downloadDto.url,
- { method: HTTP_METHOD.HEAD, ...identityEncodingConfig },
+ { method: HTTP_METHOD.HEAD, signal: options?.signal, ...identityEncodingConfig },
{ allowPrivateIP: options?.allowPrivateIP }
)
@@ -72,10 +68,14 @@ export class DownloadFile {
// The HEAD request resolved redirects; the GET must target that final URL directly.
const { response: getRes } = await this.request(
url,
- { method: HTTP_METHOD.GET, responseType: 'stream', ...identityEncodingConfig },
+ { method: HTTP_METHOD.GET, responseType: 'stream', signal: options?.signal, ...identityEncodingConfig },
{ allowPrivateIP: options?.allowPrivateIP, maxRedirects: 0 }
)
- await writeFromStream(dstPath, getRes.data, 0, maxSize)
+ if (options?.signal) {
+ await writeFromStream(dstPath, getRes.data, 0, maxSize, options.signal)
+ } else {
+ await writeFromStream(dstPath, getRes.data, 0, maxSize)
+ }
}
private safeLookup(hostname: string, options: Parameters<LookupFunction>[1], cb: Parameters<LookupFunction>[2]): void {
diff --git a/backend/src/applications/files/utils/files.spec.ts b/backend/src/applications/files/utils/files.spec.ts
index 262f55ea..7d78dfff 100644
--- a/backend/src/applications/files/utils/files.spec.ts
+++ b/backend/src/applications/files/utils/files.spec.ts
@@ -65,6 +65,16 @@ describe(writeFromStream.name, () => {
await expect(readFile(filePath, 'utf8')).resolves.toBe('abcde')
})
+
+ it('aborts a stream when its signal is already aborted', async () => {
+ const filePath = path.join(tmpDir, 'file.txt')
+ const controller = new AbortController()
+ controller.abort()
+
+ await expect(writeFromStream(filePath, Readable.from([Buffer.from('abc')]), 0, undefined, controller.signal)).rejects.toMatchObject({
+ name: 'AbortError'
+ })
+ })
})
describe(makeTempDir.name, () => {
diff --git a/backend/src/applications/files/utils/files.ts b/backend/src/applications/files/utils/files.ts
index 39e6c791..6ad551c9 100644
--- a/backend/src/applications/files/utils/files.ts
+++ b/backend/src/applications/files/utils/files.ts
@@ -199,10 +199,10 @@ export async function checksumFile(filePath: string, alg: string): Promise<strin
return hash.digest('hex')
}
-export function writeFromStream(rPath: string, stream: Readable, start: number = 0, maxSize?: number): Promise<void> {
+export function writeFromStream(rPath: string, stream: Readable, start: number = 0, maxSize?: number, signal?: AbortSignal): Promise<void> {
const dst: WriteStream = createWriteStream(rPath, { flags: start ? 'a' : 'w', start: start, highWaterMark: DEFAULT_HIGH_WATER_MARK })
if (maxSize === undefined) {
- return pipeline(stream, dst)
+ return pipeline(stream, dst, { signal })
}
let received = start
const limitSize = new Transform({
@@ -215,7 +215,7 @@ export function writeFromStream(rPath: string, stream: Readable, start: number =
callback(null, chunk)
}
})
- return pipeline(stream, limitSize, dst)
+ return pipeline(stream, limitSize, dst, { signal })
}
export async function writeFromStreamAndChecksum(rPath: string, stream: Readable, hasRange: number, alg: string): Promise<string> {
diff --git a/backend/src/applications/files/utils/untar-file.ts b/backend/src/applications/files/utils/untar-file.ts
index cb92f635..e824fe24 100644
--- a/backend/src/applications/files/utils/untar-file.ts
+++ b/backend/src/applications/files/utils/untar-file.ts
@@ -21,7 +21,7 @@ export function checkTarEntry(outputDir: string, entry: Pick<ReadEntry, 'type' |
return true
}
-export async function extractTar(filePath: string, outputDir: string, gzip: boolean, maxExtractedSize?: number): Promise<void> {
+export async function extractTar(filePath: string, outputDir: string, gzip: boolean, maxExtractedSize?: number, signal?: AbortSignal): Promise<void> {
let validationError: Error | undefined
let extractedSize = 0
const srcStream = createReadStream(filePath)
@@ -55,7 +55,7 @@ export async function extractTar(filePath: string, outputDir: string, gzip: bool
}
})
try {
- await pipeline(srcStream, extractStream)
+ await pipeline(srcStream, extractStream, { signal })
} catch (e) {
throw validationError || e
}
diff --git a/backend/src/applications/files/utils/unzip-file.ts b/backend/src/applications/files/utils/unzip-file.ts
index e964458f..574c11a7 100644
--- a/backend/src/applications/files/utils/unzip-file.ts
+++ b/backend/src/applications/files/utils/unzip-file.ts
@@ -9,7 +9,7 @@ import { isPathInside, makeDir } from './files'
const openZipAsync: (path: string, options: Options) => Promise<ZipFile> = promisify(openZip)
-export async function extractZip(filePath: string, outputDir: string, maxExtractedSize?: number): Promise<void> {
+export async function extractZip(filePath: string, outputDir: string, maxExtractedSize?: number, signal?: AbortSignal): Promise<void> {
// Reject entries whose actual decompressed size differs from their metadata.
const zipFile = await openZipAsync(filePath, { lazyEntries: true, validateEntrySizes: true })
const openReadStream = promisify(zipFile.openReadStream.bind(zipFile))
@@ -17,8 +17,21 @@ export async function extractZip(filePath: string, outputDir: string, maxExtract
let extractedSize = 0
return new Promise((resolve, reject) => {
+ let settled = false
+ const cleanup = () => signal?.removeEventListener('abort', onAbort)
+ const rejectOnce = (err: unknown) => {
+ if (settled) return
+ settled = true
+ cleanup()
+ zipFile.close()
+ reject(err)
+ }
+ const onAbort = () => rejectOnce(signal?.reason)
+ signal?.addEventListener('abort', onAbort, { once: true })
+
zipFile.on('entry', async (entry: Entry) => {
try {
+ signal?.throwIfAborted()
// Check the cumulative size before opening the entry stream to avoid writing beyond the known quota.
extractedSize += entry.uncompressedSize
if (maxExtractedSize !== undefined && extractedSize > maxExtractedSize) {
@@ -36,17 +49,26 @@ export async function extractZip(filePath: string, outputDir: string, maxExtract
// make sure parent exists
await makeDir(path.dirname(fullPath), true)
const readStream = await openReadStream(entry)
- await pipeline(readStream, fs.createWriteStream(fullPath, { highWaterMark: DEFAULT_HIGH_WATER_MARK }))
+ await pipeline(readStream, fs.createWriteStream(fullPath, { highWaterMark: DEFAULT_HIGH_WATER_MARK }), { signal })
zipFile.readEntry()
}
} catch (err) {
- zipFile.close()
- reject(err)
+ rejectOnce(err)
}
})
- zipFile.on('end', resolve)
- zipFile.on('error', reject)
- zipFile.readEntry()
+ zipFile.on('end', () => {
+ if (settled) return
+ settled = true
+ cleanup()
+ resolve()
+ })
+ zipFile.on('error', rejectOnce)
+ try {
+ signal?.throwIfAborted()
+ zipFile.readEntry()
+ } catch (err) {
+ rejectOnce(err)
+ }
})
}
diff --git a/frontend/src/app/applications/files/components/sidebar/files-tasks.component.html b/frontend/src/app/applications/files/components/sidebar/files-tasks.component.html
index 0d0f9a0a..8af5262c 100644
--- a/frontend/src/app/applications/files/components/sidebar/files-tasks.component.html
+++ b/frontend/src/app/applications/files/components/sidebar/files-tasks.component.html
@@ -30,20 +30,25 @@
<div class="task-list">
<div (click)="goToFile(task)" [tooltip]="task.result | translate:locale.language" class="text-truncate" placement="bottom">
<div>
- <fa-icon [class.text-danger]="task.status >= 2" [icon]="iconsStatus[task.status]"
+ @if (canCancel(task)) {
+ <button (click)="cancelTask($event, task)" class="btn btn-sm btn-default float-end">
+ <fa-icon [icon]="icons.faStop"></fa-icon>
+ </button>
+ }
+ <fa-icon [class.text-danger]="isTaskError(task)" [class.text-muted]="isTaskCancelled(task)" [icon]="iconsStatus[task.status]"
[animation]="task.status === 0 ? 'spin-pulse' : null"></fa-icon>
<b>
<fa-icon [icon]="iconsOperation[task.type]" class="me-1"></fa-icon>
</b>
<span>{{ task.name }}</span>
</div>
- @if (task.status === 2) {
- <div [class.text-danger]="task.status >= 2" class="ms-2">{{ task.result | translate:locale.language }}</div>
+ @if (task.status >= 2) {
+ <div [class.text-danger]="isTaskError(task)" [class.text-muted]="isTaskCancelled(task)" class="ms-2">{{ task.result | translate:locale.language }}</div>
}
<div class="mt-1 fs-sm">
<progressbar [max]="100"
[value]="task.status > 0 ? 100 : task.props.progress || 100"
- [type]="task.status < 1 ? 'warning' : task.status === 2 ? 'danger' : null"
+ [type]="task.status < 1 ? 'warning' : isTaskError(task) ? 'danger' : null"
class="custom-progress-bar position-relative">
<span class="d-flex align-items-center justify-content-center position-absolute mx-1 w-100">
@if (task.props.size) {
diff --git a/frontend/src/app/applications/files/components/sidebar/files-tasks.component.ts b/frontend/src/app/applications/files/components/sidebar/files-tasks.component.ts
index 3e1186d0..b0c45cfc 100644
--- a/frontend/src/app/applications/files/components/sidebar/files-tasks.component.ts
+++ b/frontend/src/app/applications/files/components/sidebar/files-tasks.component.ts
@@ -5,6 +5,7 @@ import { IconDefinition } from '@fortawesome/fontawesome-svg-core'
import { faClock, faFile, faFileArchive, faFolderClosed, faTrashCan } from '@fortawesome/free-regular-svg-icons'
import {
faArrowsAlt,
+ faBan,
faCheck,
faClone,
faExclamation,
@@ -12,10 +13,11 @@ import {
faFlag,
faGlobe,
faSpinner,
+ faStop,
faTrashAlt
} from '@fortawesome/free-solid-svg-icons'
import { FILE_OPERATION } from '@sync-in-server/backend/src/applications/files/constants/operations'
-import { FileTask } from '@sync-in-server/backend/src/applications/files/models/file-task'
+import { FileTask, FileTaskStatus } from '@sync-in-server/backend/src/applications/files/models/file-task'
import { L10N_LOCALE, L10nLocale, L10nTranslatePipe } from 'angular-l10n'
import { ProgressbarComponent } from 'ngx-bootstrap/progressbar'
import { TooltipModule } from 'ngx-bootstrap/tooltip'
@@ -35,8 +37,8 @@ import { FilesService } from '../../services/files.service'
})
export class FilesTasksComponent implements OnDestroy {
protected readonly locale = inject<L10nLocale>(L10N_LOCALE)
- protected readonly icons = { faTrashAlt, faFlag, faClock, faFile, faFolderClosed }
- protected readonly iconsStatus: IconDefinition[] = [faSpinner, faCheck, faExclamation]
+ protected readonly icons = { faTrashAlt, faFlag, faClock, faFile, faFolderClosed, faStop }
+ protected readonly iconsStatus: IconDefinition[] = [faSpinner, faCheck, faExclamation, faBan]
protected readonly iconsOperation = {
[FILE_OPERATION.DELETE]: faTrashCan,
[FILE_OPERATION.MOVE]: faArrowsAlt,
@@ -82,6 +84,23 @@ export class FilesTasksComponent implements OnDestroy {
this.filesTasksService.removeAll()
}
+ cancelTask(event: MouseEvent, task: FileTask) {
+ event.stopPropagation()
+ this.filesTasksService.cancel(task)
+ }
+
+ canCancel(task: FileTask): boolean {
+ return this.filesTasksService.canCancel(task)
+ }
+
+ isTaskError(task: FileTask): boolean {
+ return task.status === FileTaskStatus.ERROR
+ }
+
+ isTaskCancelled(task: FileTask): boolean {
+ return task.status === FileTaskStatus.CANCELLED
+ }
+
goToFile(task: FileTask) {
if (task.status === 1) {
if (task.type === FILE_OPERATION.COMPRESS && task.props.compressInDirectory === false) {
diff --git a/frontend/src/app/applications/files/services/files-tasks.service.ts b/frontend/src/app/applications/files/services/files-tasks.service.ts
index e25df5fb..f62c92b3 100644
--- a/frontend/src/app/applications/files/services/files-tasks.service.ts
+++ b/frontend/src/app/applications/files/services/files-tasks.service.ts
@@ -1,7 +1,7 @@
import { HttpClient, HttpErrorResponse } from '@angular/common/http'
import { inject, Injectable } from '@angular/core'
import { FILE_OPERATION } from '@sync-in-server/backend/src/applications/files/constants/operations'
-import { API_FILES_TASKS } from '@sync-in-server/backend/src/applications/files/constants/routes'
+import { API_FILES_TASKS, API_FILES_TASKS_CANCEL } from '@sync-in-server/backend/src/applications/files/constants/routes'
import { FileTask, FileTaskStatus } from '@sync-in-server/backend/src/applications/files/models/file-task'
import { SPACE_REPOSITORY } from '@sync-in-server/backend/src/applications/spaces/constants/spaces'
import { currentTimeStamp } from '@sync-in-server/backend/src/common/shared'
@@ -53,6 +53,7 @@ export class FilesTasksService {
}
}
private currentUserId: number
+ private cancellingTasks = new Set<string>()
private watcher: Subscription = null
private watch = timer(1000, 1000).pipe(tap(() => this.doWatch()))
@@ -99,11 +100,31 @@ export class FilesTasksService {
})
}
+ cancel(task: FileTask) {
+ if (!this.canCancel(task)) return
+ this.cancellingTasks.add(task.id)
+ this.http.post<void>(`${API_FILES_TASKS_CANCEL}/${task.id}`, null).subscribe({
+ error: (e) => {
+ this.cancellingTasks.delete(task.id)
+ console.error(e)
+ }
+ })
+ }
+
+ canCancel(task: FileTask): boolean {
+ return (
+ task.status === FileTaskStatus.PENDING &&
+ !this.cancellingTasks.has(task.id) &&
+ (task.type === FILE_OPERATION.DOWNLOAD || task.type === FILE_OPERATION.COMPRESS || task.type === FILE_OPERATION.DECOMPRESS)
+ )
+ }
+
updateTask(task: FileTask) {
if (task.status === FileTaskStatus.PENDING) {
const currentTask = this.findTask(task.id, true)
Object.assign(currentTask, task)
} else {
+ this.cancellingTasks.delete(task.id)
this.deleteTask(task.id, true)
this.addTask(task)
this.taskDone(task)
@@ -171,6 +192,7 @@ export class FilesTasksService {
}
private taskDone(task: FileTask) {
+ if (task.status === FileTaskStatus.CANCELLED) return
if (task.type in this.onDone) {
if (this.onDone[task.type].fileEvent) {
const fileEvent: Partial<FileEvent> = { ...this.onDone[task.type].fileEvent, status: task.status }
diff --git a/frontend/src/i18n/de.json b/frontend/src/i18n/de.json
index bdcd143e..64474458 100644
--- a/frontend/src/i18n/de.json
+++ b/frontend/src/i18n/de.json
@@ -275,6 +275,7 @@
"Download": "Herunterladen",
"Download done": "Download abgeschlossen",
"Download failed": "Download fehlgeschlagen",
+ "Cancelled": "Abgebrochen",
"Upload done": "Upload abgeschlossen",
"Upload failed": "Upload fehlgeschlagen",
"Copy · Move": "Kopieren · Verschieben",
diff --git a/frontend/src/i18n/en.json b/frontend/src/i18n/en.json
index ab10b02d..c05c0bc9 100644
--- a/frontend/src/i18n/en.json
+++ b/frontend/src/i18n/en.json
@@ -20,5 +20,6 @@
"scheduler_unit_day": "days",
"no_selection": "no item selected",
"one_selection": "{{ nb }} item selected",
- "nb_selections": "{{ nb }} items selected"
+ "nb_selections": "{{ nb }} items selected",
+ "Cancelled": "Cancelled"
}
diff --git a/frontend/src/i18n/es.json b/frontend/src/i18n/es.json
index 394bda76..cd638bed 100644
--- a/frontend/src/i18n/es.json
+++ b/frontend/src/i18n/es.json
@@ -275,6 +275,7 @@
"Download": "Descargar",
"Download done": "Descarga realizada",
"Download failed": "Descarga fallida",
+ "Cancelled": "Cancelada",
"Upload done": "Envío completado",
"Upload failed": "Envío fallido",
"Copy · Move": "Copiar · Mover",
diff --git a/frontend/src/i18n/fr.json b/frontend/src/i18n/fr.json
index 8d7e9980..e520af04 100644
--- a/frontend/src/i18n/fr.json
+++ b/frontend/src/i18n/fr.json
@@ -275,6 +275,7 @@
"Download": "Télécharger",
"Download done": "Téléchargement effectué",
"Download failed": "Téléchargement échoué",
+ "Cancelled": "Annulée",
"Upload done": "Envoi terminé",
"Upload failed": "Envoi échoué",
"Copy · Move": "Copier · Déplacer",
diff --git a/frontend/src/i18n/hi.json b/frontend/src/i18n/hi.json
index 45f9c5e0..e1598ce4 100644
--- a/frontend/src/i18n/hi.json
+++ b/frontend/src/i18n/hi.json
@@ -275,6 +275,7 @@
"Download": "डाउनलोड",
"Download done": "डाउनलोड पूर्ण",
"Download failed": "डाउनलोड विफल",
+ "Cancelled": "रद्द किया गया",
"Upload done": "अपलोड पूर्ण",
"Upload failed": "अपलोड विफल",
"Copy · Move": "कॉपी · स्थानांतरित",
diff --git a/frontend/src/i18n/it.json b/frontend/src/i18n/it.json
index 07c200c9..64dafb28 100644
--- a/frontend/src/i18n/it.json
+++ b/frontend/src/i18n/it.json
@@ -275,6 +275,7 @@
"Download": "Scarica",
"Download done": "Download completato",
"Download failed": "Download non riuscito",
+ "Cancelled": "Annullata",
"Upload done": "Caricamento completato",
"Upload failed": "Caricamento non riuscito",
"Copy · Move": "Copia · Sposta",
diff --git a/frontend/src/i18n/ja.json b/frontend/src/i18n/ja.json
index 8f938b2e..32e7251d 100644
--- a/frontend/src/i18n/ja.json
+++ b/frontend/src/i18n/ja.json
@@ -275,6 +275,7 @@
"Download": "ダウンロード",
"Download done": "ダウンロード完了",
"Download failed": "ダウンロード失敗",
+ "Cancelled": "キャンセル済み",
"Upload done": "アップロード完了",
"Upload failed": "アップロード失敗",
"Copy · Move": "コピー · 移動",
diff --git a/frontend/src/i18n/ko.json b/frontend/src/i18n/ko.json
index c0a307b0..f9797397 100644
--- a/frontend/src/i18n/ko.json
+++ b/frontend/src/i18n/ko.json
@@ -275,6 +275,7 @@
"Download": "다운로드",
"Download done": "다운로드 완료",
"Download failed": "다운로드 실패",
+ "Cancelled": "취소됨",
"Upload done": "업로드 완료",
"Upload failed": "업로드 실패",
"Copy · Move": "복사 · 이동",
diff --git a/frontend/src/i18n/nl.json b/frontend/src/i18n/nl.json
index f47c3fef..93772d22 100644
--- a/frontend/src/i18n/nl.json
+++ b/frontend/src/i18n/nl.json
@@ -275,6 +275,7 @@
"Download": "Downloaden",
"Download done": "Downloaden voltooid",
"Download failed": "Downloaden mislukt",
+ "Cancelled": "Geannuleerd",
"Upload done": "Uploaden voltooid",
"Upload failed": "Uploaden mislukt",
"Copy · Move": "Kopiëren · Verplaatsen",
diff --git a/frontend/src/i18n/pl.json b/frontend/src/i18n/pl.json
index 338bf94b..baed4e47 100644
--- a/frontend/src/i18n/pl.json
+++ b/frontend/src/i18n/pl.json
@@ -275,6 +275,7 @@
"Download": "Pobierz",
"Download done": "Pobieranie zakończone",
"Download failed": "Błąd pobierania",
+ "Cancelled": "Anulowano",
"Upload done": "Przesyłanie zakończone",
"Upload failed": "Błąd przesyłania",
"Copy · Move": "Kopiuj · Przenieś",
diff --git a/frontend/src/i18n/pt-BR.json b/frontend/src/i18n/pt-BR.json
index ad63362b..2a4d83aa 100644
--- a/frontend/src/i18n/pt-BR.json
+++ b/frontend/src/i18n/pt-BR.json
@@ -275,6 +275,7 @@
"Download": "Baixar",
"Download done": "Download concluído",
"Download failed": "Falha no download",
+ "Cancelled": "Cancelada",
"Upload done": "Envio concluído",
"Upload failed": "Falha no envio",
"Copy · Move": "Copiar · Mover",
diff --git a/frontend/src/i18n/pt.json b/frontend/src/i18n/pt.json
index a9e8c329..91ab762e 100644
--- a/frontend/src/i18n/pt.json
+++ b/frontend/src/i18n/pt.json
@@ -275,6 +275,7 @@
"Download": "Baixar",
"Download done": "Download concluído",
"Download failed": "Falha no download",
+ "Cancelled": "Cancelada",
"Upload done": "Envio concluído",
"Upload failed": "Falha no envio",
"Copy · Move": "Copiar · Mover",
diff --git a/frontend/src/i18n/ru.json b/frontend/src/i18n/ru.json
index db938d7b..a6e2ee28 100644
--- a/frontend/src/i18n/ru.json
+++ b/frontend/src/i18n/ru.json
@@ -275,6 +275,7 @@
"Download": "Скачать",
"Download done": "Загрузка завершена",
"Download failed": "Ошибка загрузки",
+ "Cancelled": "Отменено",
"Upload done": "Загрузка завершена",
"Upload failed": "Ошибка отправки",
"Copy · Move": "Копировать · Переместить",
diff --git a/frontend/src/i18n/tr.json b/frontend/src/i18n/tr.json
index b7208a25..2759120a 100644
--- a/frontend/src/i18n/tr.json
+++ b/frontend/src/i18n/tr.json
@@ -275,6 +275,7 @@
"Download": "İndir",
"Download done": "İndirme tamamlandı",
"Download failed": "İndirme başarısız",
+ "Cancelled": "İptal edildi",
"Upload done": "Yükleme tamamlandı",
"Upload failed": "Yükleme başarısız",
"Copy · Move": "Kopyala · Taşı",
diff --git a/frontend/src/i18n/zh.json b/frontend/src/i18n/zh.json
index 1dd105a7..1e3d9afd 100644
--- a/frontend/src/i18n/zh.json
+++ b/frontend/src/i18n/zh.json
@@ -275,6 +275,7 @@
"Download": "下载",
"Download done": "下载完成",
"Download failed": "下载失败",
+ "Cancelled": "已取消",
"Upload done": "上传完成",
"Upload failed": "上传失败",
"Copy · Move": "复制 · 移动",