Skip to content

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

refactor(backend:files): unify storage quota exceeded message

johaven7a882eeace21
diff --git a/backend/src/applications/files/constants/errors.ts b/backend/src/applications/files/constants/errors.ts
new file mode 100644
index 00000000..a86dc505
--- /dev/null
+++ b/backend/src/applications/files/constants/errors.ts
@@ -0,0 +1,9 @@
+export const FILE_ERROR = {
+ DOWNLOAD_PRIVATE_IP: 'Access to internal IP addresses is forbidden',
+ DOWNLOAD_INVALID_CONTENT_LENGTH: 'Missing or invalid "content-length" header',
+ DOWNLOAD_MAX_REDIRECTS_EXCEEDED: 'Maximum redirects exceeded',
+ DOWNLOAD_MISSING_REDIRECT_LOCATION: 'Missing redirect location',
+ DOWNLOAD_UNSAFE_REDIRECT_LOCATION: 'Unsafe redirect location',
+ MAX_FILE_SIZE_EXCEEDED: 'File size limit exceeded',
+ STORAGE_QUOTA_EXCEEDED: 'Storage quota exceeded'
+} as const
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 220d6960..50dc68d1 100644
--- a/backend/src/applications/files/services/files-manager.service.spec.ts
+++ b/backend/src/applications/files/services/files-manager.service.spec.ts
@@ -17,7 +17,6 @@ import { DownloadFileDto } from '../dto/file-operations.dto'
import { FileEvent, FileTaskEvent } from '../events/file-events'
import { FileError, SourceCleanupError } from '../models/file-error'
import { LockConflict } from '../models/file-lock-error'
-import { FILE_ERROR_MESSAGES } from '../utils/errors'
import { SendFile } from '../utils/send-file'
import * as unzipUtils from '../utils/unzip-file'
import * as untarUtils from '../utils/untar-file'
@@ -30,6 +29,7 @@ import { FilesManager } from './files-manager.service'
import { FilesQueries } from './files-queries.service'
import { FilesTasksTransfer } from './tasks/files-tasks-transfer.service'
import { Mock } from 'vitest'
+import { FILE_ERROR } from '../constants/errors'
vi.mock('node:dns/promises', () => ({
lookup: vi.fn()
@@ -528,7 +528,7 @@ describe(FilesManager.name, () => {
}
await expect(service.saveMultipart(user, space, req as any)).rejects.toEqual(
- new FileError(HttpStatus.PAYLOAD_TOO_LARGE, FILE_ERROR_MESSAGES.MAX_FILE_SIZE_EXCEEDED)
+ new FileError(HttpStatus.PAYLOAD_TOO_LARGE, FILE_ERROR.MAX_FILE_SIZE_EXCEEDED)
)
const tmpWritePath = vi.mocked(filesUtils.writeFromStream).mock.calls[0][0] as string
@@ -557,7 +557,7 @@ describe(FilesManager.name, () => {
}
await expect(service.saveMultipart(user, space, req as any)).rejects.toEqual(
- new FileError(HttpStatus.PAYLOAD_TOO_LARGE, FILE_ERROR_MESSAGES.MAX_FILE_SIZE_EXCEEDED)
+ new FileError(HttpStatus.PAYLOAD_TOO_LARGE, FILE_ERROR.MAX_FILE_SIZE_EXCEEDED)
)
expect(req.files).toHaveBeenCalled()
@@ -581,7 +581,7 @@ describe(FilesManager.name, () => {
}
await expect(service.saveMultipart(user, space, req as any)).rejects.toEqual(
- new FileError(HttpStatus.PAYLOAD_TOO_LARGE, FILE_ERROR_MESSAGES.MAX_FILE_SIZE_EXCEEDED)
+ new FileError(HttpStatus.PAYLOAD_TOO_LARGE, FILE_ERROR.MAX_FILE_SIZE_EXCEEDED)
)
expect(filesUtils.writeFromStream).not.toHaveBeenCalled()
@@ -1085,7 +1085,7 @@ describe(FilesManager.name, () => {
})
it('should cleanup partial file and skip ADD event when download write fails', async () => {
- const error = new FileError(HttpStatus.PAYLOAD_TOO_LARGE, FILE_ERROR_MESSAGES.MAX_FILE_SIZE_EXCEEDED)
+ const error = new FileError(HttpStatus.PAYLOAD_TOO_LARGE, FILE_ERROR.MAX_FILE_SIZE_EXCEEDED)
const space = makeSpace()
vi.mocked(filesUtils.uniqueFilePathFromDir).mockResolvedValueOnce('/tmp/download.txt')
vi.mocked(filesUtils.tempFilePath).mockReturnValueOnce('/data/users/john/tmp/download.txt-download-uuid')
diff --git a/backend/src/applications/files/services/files-manager.service.ts b/backend/src/applications/files/services/files-manager.service.ts
index 3c0db399..a7543766 100644
--- a/backend/src/applications/files/services/files-manager.service.ts
+++ b/backend/src/applications/files/services/files-manager.service.ts
@@ -62,11 +62,12 @@ import { FilesQueries } from './files-queries.service'
import { FileEvent, FileTaskEvent } from '../events/file-events'
import { ACTION } from '../../../common/constants'
import { isMultipartFileTooLargeError, uploadTmpFilePath } from '../utils/upload-file'
-import { FILE_ERROR_MESSAGES, maxFileSizeExceededError } from '../utils/errors'
+import { maxFileSizeExceededError } from '../utils/errors'
import { createTaskTemporaryDir, taskTemporaryPath } from '../utils/tasks'
import { FilesTasksTransfer } from './tasks/files-tasks-transfer.service'
import { createTar } from '../utils/tar-file'
import { createZip } from '../utils/zip-file'
+import { FILE_ERROR } from '../constants/errors'
@Injectable()
export class FilesManager {
@@ -403,7 +404,7 @@ export class FilesManager {
}
if (dstSpace.quotaIsExceeded) {
this.logger.warn({ tag: this.copyMove.name, msg: `quota is exceeded for *${dstSpace.alias}* (${dstSpace.id})` })
- throw new FileError(HttpStatus.INSUFFICIENT_STORAGE, 'Quota is exceeded')
+ throw new FileError(HttpStatus.INSUFFICIENT_STORAGE, FILE_ERROR.STORAGE_QUOTA_EXCEEDED)
}
if (!(await isPathExists(srcSpace.realPath))) {
throw new FileError(HttpStatus.NOT_FOUND, 'Location not found')
@@ -453,8 +454,8 @@ export class FilesManager {
if (!isMove || (isMove && srcSpace.id !== dstSpace.id)) {
const size = isDir ? (await dirSize(srcSpace.realPath))[0] : await fileSize(srcSpace.realPath)
if (dstSpace.willExceedQuota(size)) {
- this.logger.warn({ tag: this.copyMove.name, msg: `${FILE_ERROR_MESSAGES.STORAGE_QUOTA_EXCEEDED} for *${dstSpace.alias}* (${dstSpace.id})` })
- throw new FileError(HttpStatus.INSUFFICIENT_STORAGE, FILE_ERROR_MESSAGES.STORAGE_QUOTA_EXCEEDED)
+ this.logger.warn({ tag: this.copyMove.name, msg: `${FILE_ERROR.STORAGE_QUOTA_EXCEEDED} for *${dstSpace.alias}* (${dstSpace.id})` })
+ throw new FileError(HttpStatus.INSUFFICIENT_STORAGE, FILE_ERROR.STORAGE_QUOTA_EXCEEDED)
}
}
}
diff --git a/backend/src/applications/files/utils/download-file.spec.ts b/backend/src/applications/files/utils/download-file.spec.ts
index a92ffb7f..566a0150 100644
--- a/backend/src/applications/files/utils/download-file.spec.ts
+++ b/backend/src/applications/files/utils/download-file.spec.ts
@@ -4,10 +4,10 @@ import { HttpStatus } from '@nestjs/common'
import { Readable } from 'node:stream'
import { HTTP_METHOD } from '../../applications.constants'
import { FileError } from '../models/file-error'
-import { FILE_ERROR_MESSAGES } from './errors'
import { writeFromStream } from './files'
import { DownloadFile } from './download-file'
import type { Mock } from 'vitest'
+import { FILE_ERROR } from '../constants/errors'
vi.mock('./files', () => ({
writeFromStream: vi.fn()
@@ -58,7 +58,7 @@ describe(DownloadFile.name, () => {
await expect(
new DownloadFile(http as unknown as HttpService).download({ url: 'https://example.test/file.txt' }, '/tmp/file.txt')
- ).rejects.toEqual(new FileError(HttpStatus.FORBIDDEN, FILE_ERROR_MESSAGES.DOWNLOAD_PRIVATE_IP))
+ ).rejects.toEqual(new FileError(HttpStatus.FORBIDDEN, FILE_ERROR.DOWNLOAD_PRIVATE_IP))
expect(http.axiosRef).toHaveBeenCalledTimes(1)
expect(http.axiosRef).toHaveBeenCalledWith(
@@ -72,7 +72,7 @@ describe(DownloadFile.name, () => {
await expect(
new DownloadFile(http as unknown as HttpService).download({ url: 'https://example.test/file.txt' }, '/tmp/file.txt')
- ).rejects.toEqual(new FileError(HttpStatus.FORBIDDEN, FILE_ERROR_MESSAGES.DOWNLOAD_PRIVATE_IP))
+ ).rejects.toEqual(new FileError(HttpStatus.FORBIDDEN, FILE_ERROR.DOWNLOAD_PRIVATE_IP))
expect(lookupMock).toHaveBeenCalledWith('example.test', { all: true, order: 'verbatim' })
expect(http.axiosRef).not.toHaveBeenCalled()
@@ -87,7 +87,7 @@ describe(DownloadFile.name, () => {
await expect(
new DownloadFile(http as unknown as HttpService).download({ url: 'https://example.test/file.txt' }, '/tmp/file.txt')
- ).rejects.toEqual(new FileError(HttpStatus.FORBIDDEN, FILE_ERROR_MESSAGES.DOWNLOAD_PRIVATE_IP))
+ ).rejects.toEqual(new FileError(HttpStatus.FORBIDDEN, FILE_ERROR.DOWNLOAD_PRIVATE_IP))
expect(http.axiosRef).not.toHaveBeenCalled()
expect(writeFromStream).not.toHaveBeenCalled()
@@ -124,7 +124,7 @@ describe(DownloadFile.name, () => {
await expect(
new DownloadFile(http as unknown as HttpService).download({ url: 'https://example.test/file.txt' }, '/tmp/file.txt')
- ).rejects.toEqual(new FileError(HttpStatus.FORBIDDEN, FILE_ERROR_MESSAGES.DOWNLOAD_PRIVATE_IP))
+ ).rejects.toEqual(new FileError(HttpStatus.FORBIDDEN, FILE_ERROR.DOWNLOAD_PRIVATE_IP))
expect(http.axiosRef).toHaveBeenCalledTimes(1)
expect(writeFromStream).not.toHaveBeenCalled()
@@ -135,7 +135,7 @@ describe(DownloadFile.name, () => {
await expect(
new DownloadFile(http as unknown as HttpService).download({ url: 'https://example.test/file.txt' }, '/tmp/file.txt')
- ).rejects.toEqual(new FileError(HttpStatus.FORBIDDEN, FILE_ERROR_MESSAGES.DOWNLOAD_PRIVATE_IP))
+ ).rejects.toEqual(new FileError(HttpStatus.FORBIDDEN, FILE_ERROR.DOWNLOAD_PRIVATE_IP))
expect(http.axiosRef).toHaveBeenCalledTimes(1)
expect(writeFromStream).not.toHaveBeenCalled()
@@ -185,7 +185,7 @@ describe(DownloadFile.name, () => {
await expect(
new DownloadFile(http as unknown as HttpService).download({ url: 'https://example.test/file.txt' }, '/tmp/file.txt', { getContentInfo: true })
- ).rejects.toEqual(new FileError(HttpStatus.FORBIDDEN, FILE_ERROR_MESSAGES.DOWNLOAD_PRIVATE_IP))
+ ).rejects.toEqual(new FileError(HttpStatus.FORBIDDEN, FILE_ERROR.DOWNLOAD_PRIVATE_IP))
expect(writeFromStream).not.toHaveBeenCalled()
})
@@ -222,7 +222,7 @@ describe(DownloadFile.name, () => {
await expect(
new DownloadFile(http as unknown as HttpService).download({ url: 'https://example.test/file.txt' }, '/tmp/file.txt')
- ).rejects.toEqual(new FileError(HttpStatus.FORBIDDEN, FILE_ERROR_MESSAGES.DOWNLOAD_PRIVATE_IP))
+ ).rejects.toEqual(new FileError(HttpStatus.FORBIDDEN, FILE_ERROR.DOWNLOAD_PRIVATE_IP))
expect(destroySpy).toHaveBeenCalled()
expect(writeFromStream).not.toHaveBeenCalled()
@@ -233,7 +233,7 @@ describe(DownloadFile.name, () => {
await expect(
new DownloadFile(http as unknown as HttpService).download({ url: 'https://example.test/file.txt' }, '/tmp/file.txt')
- ).rejects.toEqual(new FileError(HttpStatus.BAD_REQUEST, FILE_ERROR_MESSAGES.DOWNLOAD_INVALID_CONTENT_LENGTH))
+ ).rejects.toEqual(new FileError(HttpStatus.BAD_REQUEST, FILE_ERROR.DOWNLOAD_INVALID_CONTENT_LENGTH))
expect(http.axiosRef).toHaveBeenCalledTimes(1)
expect(writeFromStream).not.toHaveBeenCalled()
@@ -259,7 +259,7 @@ describe(DownloadFile.name, () => {
space: space as any,
maxSize: 1024
})
- ).rejects.toEqual(new FileError(HttpStatus.BAD_REQUEST, FILE_ERROR_MESSAGES.DOWNLOAD_INVALID_CONTENT_LENGTH))
+ ).rejects.toEqual(new FileError(HttpStatus.BAD_REQUEST, FILE_ERROR.DOWNLOAD_INVALID_CONTENT_LENGTH))
expect(space.willExceedQuota).not.toHaveBeenCalled()
expect(writeFromStream).not.toHaveBeenCalled()
@@ -315,7 +315,7 @@ describe(DownloadFile.name, () => {
await expect(
new DownloadFile(http as unknown as HttpService).download({ url: 'https://example.test/file.txt' }, '/tmp/file.txt')
- ).rejects.toEqual(new FileError(HttpStatus.BAD_REQUEST, FILE_ERROR_MESSAGES.DOWNLOAD_MAX_REDIRECTS_EXCEEDED))
+ ).rejects.toEqual(new FileError(HttpStatus.BAD_REQUEST, FILE_ERROR.DOWNLOAD_MAX_REDIRECTS_EXCEEDED))
expect(http.axiosRef).toHaveBeenCalledTimes(2)
expect(destroySpy).toHaveBeenCalled()
diff --git a/backend/src/applications/files/utils/download-file.ts b/backend/src/applications/files/utils/download-file.ts
index 6e05e8da..5965c397 100644
--- a/backend/src/applications/files/utils/download-file.ts
+++ b/backend/src/applications/files/utils/download-file.ts
@@ -13,8 +13,8 @@ import type { DownloadFileDto } from '../dto/file-operations.dto'
import { FileTaskEvent } from '../events/file-events'
import type { DownloadFileContentInfo, DownloadFileOptions } from '../interfaces/download-file.interface'
import { FileError } from '../models/file-error'
-import { FILE_ERROR_MESSAGES } from './errors'
import { writeFromStream } from './files'
+import { FILE_ERROR } from '../constants/errors'
interface DownloadFileRequestOptions {
allowPrivateIP?: boolean
@@ -60,7 +60,7 @@ export class DownloadFile {
const maxSize = options?.space ? contentLength : (options?.maxSize ?? contentLength)
if (maxSize === null || (contentLength === null && options?.space)) {
- throw new FileError(HttpStatus.BAD_REQUEST, FILE_ERROR_MESSAGES.DOWNLOAD_INVALID_CONTENT_LENGTH)
+ throw new FileError(HttpStatus.BAD_REQUEST, FILE_ERROR.DOWNLOAD_INVALID_CONTENT_LENGTH)
}
if (contentLength !== null) this.prepareSpace(options?.space, contentLength, options?.publishedPath || dstPath)
@@ -78,7 +78,7 @@ export class DownloadFile {
.then((addresses) => {
const family = options.family === 4 || options.family === 'IPv4' ? 4 : options.family === 6 || options.family === 'IPv6' ? 6 : null
const matches = family ? addresses.filter((a) => a.family === family) : addresses
- if (!matches.length) return cb(new FileError(HttpStatus.FORBIDDEN, FILE_ERROR_MESSAGES.DOWNLOAD_PRIVATE_IP), '', 0)
+ if (!matches.length) return cb(new FileError(HttpStatus.FORBIDDEN, FILE_ERROR.DOWNLOAD_PRIVATE_IP), '', 0)
if (options.all) {
cb(null, matches)
} else {
@@ -116,7 +116,7 @@ export class DownloadFile {
response.data?.destroy?.()
// Redirects are followed manually to re-run DNS and remote address checks on each hop.
if (redirects >= (options.maxRedirects ?? DownloadFile.maxRedirects)) {
- throw new FileError(HttpStatus.BAD_REQUEST, FILE_ERROR_MESSAGES.DOWNLOAD_MAX_REDIRECTS_EXCEEDED)
+ throw new FileError(HttpStatus.BAD_REQUEST, FILE_ERROR.DOWNLOAD_MAX_REDIRECTS_EXCEEDED)
}
currentUrl = nextUrl
}
@@ -125,11 +125,11 @@ export class DownloadFile {
private redirectUrl(response: AxiosResponse, currentUrl: string): string | null {
if (!DownloadFile.redirectStatus.has(response.status)) return null
const location = response.headers.location as string | undefined
- if (!location) throw new FileError(HttpStatus.BAD_REQUEST, FILE_ERROR_MESSAGES.DOWNLOAD_MISSING_REDIRECT_LOCATION)
+ if (!location) throw new FileError(HttpStatus.BAD_REQUEST, FILE_ERROR.DOWNLOAD_MISSING_REDIRECT_LOCATION)
const url = new URL(location, currentUrl)
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
- throw new FileError(HttpStatus.FORBIDDEN, FILE_ERROR_MESSAGES.DOWNLOAD_UNSAFE_REDIRECT_LOCATION)
+ throw new FileError(HttpStatus.FORBIDDEN, FILE_ERROR.DOWNLOAD_UNSAFE_REDIRECT_LOCATION)
}
return url.toString()
}
@@ -142,7 +142,7 @@ export class DownloadFile {
const addresses = await lookup(key, DownloadFile.dnsOptions)
if (!addresses.length || addresses.some((a) => this.isBlocked(a.address))) {
- throw new FileError(HttpStatus.FORBIDDEN, FILE_ERROR_MESSAGES.DOWNLOAD_PRIVATE_IP)
+ throw new FileError(HttpStatus.FORBIDDEN, FILE_ERROR.DOWNLOAD_PRIVATE_IP)
}
this.dnsCache.set(key, addresses)
return addresses
@@ -154,7 +154,7 @@ export class DownloadFile {
private checkRemote(response: AxiosResponse, allowPrivateIP?: boolean): void {
if (!allowPrivateIP && this.isBlocked(response.request?.socket?.remoteAddress)) {
- throw new FileError(HttpStatus.FORBIDDEN, FILE_ERROR_MESSAGES.DOWNLOAD_PRIVATE_IP)
+ throw new FileError(HttpStatus.FORBIDDEN, FILE_ERROR.DOWNLOAD_PRIVATE_IP)
}
}
@@ -171,7 +171,7 @@ export class DownloadFile {
private prepareSpace(space: SpaceEnv | undefined, contentLength: number, publishedPath: string): void {
if (!space) return
if (space.willExceedQuota(contentLength)) {
- throw new FileError(HttpStatus.INSUFFICIENT_STORAGE, FILE_ERROR_MESSAGES.STORAGE_QUOTA_EXCEEDED)
+ throw new FileError(HttpStatus.INSUFFICIENT_STORAGE, FILE_ERROR.STORAGE_QUOTA_EXCEEDED)
}
if (space.task?.cacheKey) {
space.task.props = { ...space.task.props, progress: 1, size: 0, totalSize: contentLength }
diff --git a/backend/src/applications/files/utils/errors.ts b/backend/src/applications/files/utils/errors.ts
index e11aa651..3676cc3d 100644
--- a/backend/src/applications/files/utils/errors.ts
+++ b/backend/src/applications/files/utils/errors.ts
@@ -1,20 +1,11 @@
import { FileError } from '../models/file-error'
import { HttpStatus } from '@nestjs/common'
-
-export const FILE_ERROR_MESSAGES = {
- DOWNLOAD_PRIVATE_IP: 'Access to internal IP addresses is forbidden',
- DOWNLOAD_INVALID_CONTENT_LENGTH: 'Missing or invalid "content-length" header',
- DOWNLOAD_MAX_REDIRECTS_EXCEEDED: 'Maximum redirects exceeded',
- DOWNLOAD_MISSING_REDIRECT_LOCATION: 'Missing redirect location',
- DOWNLOAD_UNSAFE_REDIRECT_LOCATION: 'Unsafe redirect location',
- MAX_FILE_SIZE_EXCEEDED: 'File size limit exceeded',
- STORAGE_QUOTA_EXCEEDED: 'Storage quota will be exceeded'
-} as const
+import { FILE_ERROR } from '../constants/errors'
export function maxFileSizeExceededError(): FileError {
- return new FileError(HttpStatus.PAYLOAD_TOO_LARGE, FILE_ERROR_MESSAGES.MAX_FILE_SIZE_EXCEEDED)
+ return new FileError(HttpStatus.PAYLOAD_TOO_LARGE, FILE_ERROR.MAX_FILE_SIZE_EXCEEDED)
}
export function storageQuotaExceededError(): FileError {
- return new FileError(HttpStatus.INSUFFICIENT_STORAGE, FILE_ERROR_MESSAGES.STORAGE_QUOTA_EXCEEDED)
+ return new FileError(HttpStatus.INSUFFICIENT_STORAGE, FILE_ERROR.STORAGE_QUOTA_EXCEEDED)
}
diff --git a/backend/src/applications/files/utils/files.spec.ts b/backend/src/applications/files/utils/files.spec.ts
index 11d49093..f35be6b9 100644
--- a/backend/src/applications/files/utils/files.spec.ts
+++ b/backend/src/applications/files/utils/files.spec.ts
@@ -6,8 +6,9 @@ import { Readable } from 'node:stream'
import fse from 'fs-extra'
import type { MockInstance } from 'vitest'
import { FileError } from '../models/file-error'
-import { FILE_ERROR_MESSAGES, storageQuotaExceededError } from './errors'
+import { storageQuotaExceededError } from './errors'
import { createSizeLimiter, isCrossDevice, isPathInside, makeTempDir, tempFilePath, writeFromStream } from './files'
+import { FILE_ERROR } from '../constants/errors'
describe(createSizeLimiter.name, () => {
it('rejects the call that makes the cumulative size exceed the limit', () => {
@@ -23,7 +24,7 @@ describe(createSizeLimiter.name, () => {
}
expect(sizeError).toMatchObject({
httpCode: HttpStatus.INSUFFICIENT_STORAGE,
- message: FILE_ERROR_MESSAGES.STORAGE_QUOTA_EXCEEDED,
+ message: FILE_ERROR.STORAGE_QUOTA_EXCEEDED,
name: FileError.name
})
})
@@ -88,7 +89,7 @@ describe(writeFromStream.name, () => {
await expect(writeFromStream(filePath, Readable.from([Buffer.from('abcd')]), 0, 3)).rejects.toMatchObject({
httpCode: HttpStatus.PAYLOAD_TOO_LARGE,
- message: FILE_ERROR_MESSAGES.MAX_FILE_SIZE_EXCEEDED,
+ message: FILE_ERROR.MAX_FILE_SIZE_EXCEEDED,
name: FileError.name
})
})
diff --git a/backend/src/applications/files/utils/tar-file.spec.ts b/backend/src/applications/files/utils/tar-file.spec.ts
index b7143813..69bba171 100644
--- a/backend/src/applications/files/utils/tar-file.spec.ts
+++ b/backend/src/applications/files/utils/tar-file.spec.ts
@@ -109,7 +109,7 @@ describe(createTar.name, () => {
await writeFile(sourceFile, 'content')
await expect(createTar(archivePath, [{ path: sourceFile, name: 'file.txt' }], false, undefined, undefined, 1)).rejects.toThrow(
- 'Storage quota will be exceeded'
+ 'Storage quota exceeded'
)
})
diff --git a/backend/src/applications/files/utils/untar-file.spec.ts b/backend/src/applications/files/utils/untar-file.spec.ts
index 85950639..d78f2cdc 100644
--- a/backend/src/applications/files/utils/untar-file.spec.ts
+++ b/backend/src/applications/files/utils/untar-file.spec.ts
@@ -58,7 +58,7 @@ describe(extractTar.name, () => {
await createArchive(true)
const destroySpy = vi.spyOn(fs.ReadStream.prototype, 'destroy')
- await expect(extractTar(archivePath, outputDir, true, 1)).rejects.toThrow('Storage quota will be exceeded')
+ await expect(extractTar(archivePath, outputDir, true, 1)).rejects.toThrow('Storage quota exceeded')
expect(destroySpy).toHaveBeenCalled()
})
diff --git a/backend/src/applications/files/utils/unzip-file.spec.ts b/backend/src/applications/files/utils/unzip-file.spec.ts
index 664dc8b0..2775e4ba 100644
--- a/backend/src/applications/files/utils/unzip-file.spec.ts
+++ b/backend/src/applications/files/utils/unzip-file.spec.ts
@@ -77,6 +77,6 @@ describe(extractZip.name, () => {
it('rejects entries exceeding the extracted size limit', async () => {
await writeFile(archivePath, createZip('large.txt', Buffer.from('ab')))
- await expect(extractZip(archivePath, outputDir, 1)).rejects.toThrow('Storage quota will be exceeded')
+ await expect(extractZip(archivePath, outputDir, 1)).rejects.toThrow('Storage quota exceeded')
})
})
diff --git a/backend/src/applications/files/utils/zip-file.spec.ts b/backend/src/applications/files/utils/zip-file.spec.ts
index df9cedd6..3fbf6845 100644
--- a/backend/src/applications/files/utils/zip-file.spec.ts
+++ b/backend/src/applications/files/utils/zip-file.spec.ts
@@ -142,7 +142,7 @@ describe(createZip.name, () => {
await writeFile(sourceFile, 'content')
await expect(createZip(archivePath, [{ path: sourceFile, name: 'file.txt' }], true, undefined, undefined, 1)).rejects.toThrow(
- 'Storage quota will be exceeded'
+ 'Storage quota exceeded'
)
})
diff --git a/backend/src/applications/spaces/guards/space.guard.ts b/backend/src/applications/spaces/guards/space.guard.ts
index 4904d18e..8e4b50bd 100644
--- a/backend/src/applications/spaces/guards/space.guard.ts
+++ b/backend/src/applications/spaces/guards/space.guard.ts
@@ -1,6 +1,7 @@
import { CanActivate, ExecutionContext, HttpException, HttpStatus, Injectable, Logger } from '@nestjs/common'
import { Reflector } from '@nestjs/core'
import { HTTP_METHOD } from '../../applications.constants'
+import { FILE_ERROR } from '../../files/constants/errors'
import { COLLABORA_CONTEXT } from '../../files/editors/collabora-online/collabora-online.constants'
import { COLLABORA_ONLINE_TO_SPACE_SEGMENTS } from '../../files/editors/collabora-online/collabora-online.utils'
import { isPathExists, isPathIsDir } from '../../files/utils/files'
@@ -17,7 +18,6 @@ import { SpaceEnv } from '../models/space-env.model'
import { SpacesManager } from '../services/spaces-manager.service'
import { canAccessToSpaceUrl, haveSpaceEnvPermissions } from '../utils/permissions'
import { PATH_TO_SPACE_SEGMENTS } from '../utils/routes'
-import { FILE_ERROR_MESSAGES } from '../../files/utils/errors'
@Injectable()
export class SpaceGuard implements CanActivate {
@@ -48,11 +48,11 @@ export class SpaceGuard implements CanActivate {
}
if (req.space.quotaIsExceeded) {
logger.warn(`Storage quota exceeded for *${req.space.alias}* (${req.space.id})`)
- throw new HttpException('Storage quota exceeded', HttpStatus.INSUFFICIENT_STORAGE)
+ throw new HttpException(FILE_ERROR.STORAGE_QUOTA_EXCEEDED, HttpStatus.INSUFFICIENT_STORAGE)
} else if (req.space.storageQuota) {
const contentLength = parseInt(req.headers['content-length'] || '0', 10) || 0
if (req.space.willExceedQuota(contentLength)) {
- throw new HttpException(FILE_ERROR_MESSAGES.STORAGE_QUOTA_EXCEEDED, HttpStatus.INSUFFICIENT_STORAGE)
+ throw new HttpException(FILE_ERROR.STORAGE_QUOTA_EXCEEDED, HttpStatus.INSUFFICIENT_STORAGE)
}
}
}
diff --git a/backend/src/applications/sync/services/sync-manager.service.ts b/backend/src/applications/sync/services/sync-manager.service.ts
index 5f63c8ec..aa672ee5 100644
--- a/backend/src/applications/sync/services/sync-manager.service.ts
+++ b/backend/src/applications/sync/services/sync-manager.service.ts
@@ -4,6 +4,7 @@ import fs from 'fs/promises'
import { Dirent, Stats } from 'node:fs'
import path from 'node:path'
import { regExpPathPattern } from '../../../common/functions'
+import { FILE_ERROR } from '../../files/constants/errors'
import { FILE_OPERATION } from '../../files/constants/operations'
import { FileError } from '../../files/models/file-error'
import { LockConflict } from '../../files/models/file-lock-error'
@@ -56,7 +57,7 @@ export class SyncManager {
throw new FileError(HttpStatus.BAD_REQUEST, `sizes are not identical : ${tmpStats.size} != ${syncUploadDto.size}`)
}
if (req.space.storageQuota && req.space.willExceedQuota(tmpStats.size)) {
- throw new FileError(HttpStatus.INSUFFICIENT_STORAGE, 'Storage quota exceeded')
+ throw new FileError(HttpStatus.INSUFFICIENT_STORAGE, FILE_ERROR.STORAGE_QUOTA_EXCEEDED)
}
if (syncUploadDto.checksum && checksum !== syncUploadDto.checksum) {
throw new FileError(HttpStatus.BAD_REQUEST, 'checksums are not identical')
@@ -141,7 +142,7 @@ export class SyncManager {
throw new HttpException('Space not found', HttpStatus.NOT_FOUND)
}
if (space.quotaIsExceeded) {
- throw new HttpException('Storage quota exceeded', HttpStatus.INSUFFICIENT_STORAGE)
+ throw new HttpException(FILE_ERROR.STORAGE_QUOTA_EXCEEDED, HttpStatus.INSUFFICIENT_STORAGE)
}
if (!(await isPathExists(space.realPath))) {
throw new HttpException(`Remote path not found : ${syncPathSettings.remotePath}`, HttpStatus.NOT_FOUND)
diff --git a/backend/src/applications/sync/services/sync-paths-manager.service.ts b/backend/src/applications/sync/services/sync-paths-manager.service.ts
index da8e421e..4a68b0f7 100644
--- a/backend/src/applications/sync/services/sync-paths-manager.service.ts
+++ b/backend/src/applications/sync/services/sync-paths-manager.service.ts
@@ -2,6 +2,7 @@ import { HttpException, HttpStatus, Injectable, Logger } from '@nestjs/common'
import { ACTION } from '../../../common/constants'
import { currentTimeStamp } from '../../../common/shared'
import { ContextManager } from '../../../infrastructure/context/services/context-manager.service'
+import { FILE_ERROR } from '../../files/constants/errors'
import type { FileProps } from '../../files/interfaces/file-props.interface'
import { FilesQueries } from '../../files/services/files-queries.service'
import { getProps, isPathExists, isPathIsDir } from '../../files/utils/files'
@@ -37,7 +38,7 @@ export class SyncPathsManager {
throw new HttpException('Client id is missing', HttpStatus.BAD_REQUEST)
}
if (req.space.quotaIsExceeded) {
- throw new HttpException('Storage quota exceeded', HttpStatus.INSUFFICIENT_STORAGE)
+ throw new HttpException(FILE_ERROR.STORAGE_QUOTA_EXCEEDED, HttpStatus.INSUFFICIENT_STORAGE)
}
// Check DB path
diff --git a/frontend/src/i18n/de.json b/frontend/src/i18n/de.json
index 88718e9d..3be04303 100644
--- a/frontend/src/i18n/de.json
+++ b/frontend/src/i18n/de.json
@@ -132,7 +132,6 @@
"Storage quota exceeded": "Speicherkontingent überschritten",
"File size limit exceeded": "Dateigrößenlimit überschritten",
"The trash is read-only": "Der Papierkorb ist schreibgeschützt",
- "Storage quota will be exceeded": "Speicherkontingent wird überschritten",
"Access to internal IP addresses is forbidden": "Der Zugriff auf interne IP-Adressen ist verboten",
"Missing or invalid \"content-length\" header": "Fehlender oder ungültiger \"content-length\"-Header",
"Maximum redirects exceeded": "Maximale Anzahl an Weiterleitungen überschritten",
diff --git a/frontend/src/i18n/es.json b/frontend/src/i18n/es.json
index a6d3df6a..c3dfbd85 100644
--- a/frontend/src/i18n/es.json
+++ b/frontend/src/i18n/es.json
@@ -132,7 +132,6 @@
"Storage quota exceeded": "Se ha superado la cuota de almacenamiento",
"File size limit exceeded": "Se ha superado el límite de tamaño del archivo",
"The trash is read-only": "La papelera es de solo lectura",
- "Storage quota will be exceeded": "Se superará la cuota de almacenamiento",
"Access to internal IP addresses is forbidden": "El acceso a direcciones IP internas está prohibido",
"Missing or invalid \"content-length\" header": "Falta el encabezado \"content-length\" o no es válido",
"Maximum redirects exceeded": "Se ha superado el número máximo de redirecciones",
diff --git a/frontend/src/i18n/fr.json b/frontend/src/i18n/fr.json
index de32a1d0..26633a08 100644
--- a/frontend/src/i18n/fr.json
+++ b/frontend/src/i18n/fr.json
@@ -132,7 +132,6 @@
"Storage quota exceeded": "Le quota de stockage est dépassé",
"File size limit exceeded": "Limite de taille du fichier dépassée",
"The trash is read-only": "La corbeille est en lecture seule",
- "Storage quota will be exceeded": "Le quota de stockage sera dépassé",
"Access to internal IP addresses is forbidden": "L’accès aux adresses IP internes est interdit",
"Missing or invalid \"content-length\" header": "En-tête \"content-length\" manquant ou invalide",
"Maximum redirects exceeded": "Nombre maximal de redirections dépassé",
diff --git a/frontend/src/i18n/hi.json b/frontend/src/i18n/hi.json
index e47aeacc..0b044e54 100644
--- a/frontend/src/i18n/hi.json
+++ b/frontend/src/i18n/hi.json
@@ -132,7 +132,6 @@
"Storage quota exceeded": "भंडारण कोटा पार हो गया",
"File size limit exceeded": "फ़ाइल आकार की सीमा पार हो गई",
"The trash is read-only": "ट्रैश केवल-पढ़ने योग्य है",
- "Storage quota will be exceeded": "भंडारण कोटा पार हो जाएगा",
"Access to internal IP addresses is forbidden": "आंतरिक IP पतों तक पहुँच निषिद्ध है",
"Missing or invalid \"content-length\" header": "\"content-length\" हेडर मौजूद नहीं है या अमान्य है",
"Maximum redirects exceeded": "रीडायरेक्ट की अधिकतम संख्या पार हो गई",
diff --git a/frontend/src/i18n/it.json b/frontend/src/i18n/it.json
index b0602df9..7d3cc354 100644
--- a/frontend/src/i18n/it.json
+++ b/frontend/src/i18n/it.json
@@ -132,7 +132,6 @@
"Storage quota exceeded": "Quota di archiviazione superata",
"File size limit exceeded": "Limite di dimensione del file superato",
"The trash is read-only": "Il cestino è di sola lettura",
- "Storage quota will be exceeded": "La quota di archiviazione verrà superata",
"Access to internal IP addresses is forbidden": "L'accesso agli indirizzi IP interni è vietato",
"Missing or invalid \"content-length\" header": "Header \"content-length\" mancante o non valido",
"Maximum redirects exceeded": "Numero massimo di reindirizzamenti superato",
diff --git a/frontend/src/i18n/ja.json b/frontend/src/i18n/ja.json
index 204a88ae..d6db7380 100644
--- a/frontend/src/i18n/ja.json
+++ b/frontend/src/i18n/ja.json
@@ -132,7 +132,6 @@
"Storage quota exceeded": "ストレージの割り当てを超えています",
"File size limit exceeded": "ファイルサイズの上限を超えています",
"The trash is read-only": "ゴミ箱は読み取り専用です",
- "Storage quota will be exceeded": "ストレージの割り当てを超過する見込みです",
"Access to internal IP addresses is forbidden": "内部 IP アドレスへのアクセスは禁止されています",
"Missing or invalid \"content-length\" header": "\"content-length\" ヘッダーがないか無効です",
"Maximum redirects exceeded": "最大リダイレクト数を超えました",
diff --git a/frontend/src/i18n/ko.json b/frontend/src/i18n/ko.json
index 2fbd3e44..a1c39151 100644
--- a/frontend/src/i18n/ko.json
+++ b/frontend/src/i18n/ko.json
@@ -132,7 +132,6 @@
"Storage quota exceeded": "저장 할당량을 초과했습니다",
"File size limit exceeded": "파일 크기 제한을 초과했습니다",
"The trash is read-only": "휴지통은 읽기 전용입니다",
- "Storage quota will be exceeded": "저장 할당량을 초과할 예정입니다",
"Access to internal IP addresses is forbidden": "내부 IP 주소에 대한 접근이 금지되어 있습니다",
"Missing or invalid \"content-length\" header": "\"content-length\" 헤더가 없거나 유효하지 않습니다",
"Maximum redirects exceeded": "최대 리디렉션 수를 초과했습니다",
diff --git a/frontend/src/i18n/nl.json b/frontend/src/i18n/nl.json
index 76089fa3..45959f49 100644
--- a/frontend/src/i18n/nl.json
+++ b/frontend/src/i18n/nl.json
@@ -132,7 +132,6 @@
"Storage quota exceeded": "Opslagquotum overschreden",
"File size limit exceeded": "Limiet voor bestandsgrootte overschreden",
"The trash is read-only": "De prullenbak is alleen-lezen",
- "Storage quota will be exceeded": "Opslagquotum wordt overschreden",
"Access to internal IP addresses is forbidden": "Toegang tot interne IP-adressen is verboden",
"Missing or invalid \"content-length\" header": "Ontbrekende of ongeldige \"content-length\"-header",
"Maximum redirects exceeded": "Maximumaantal omleidingen overschreden",
diff --git a/frontend/src/i18n/pl.json b/frontend/src/i18n/pl.json
index 8ac37b9f..07d9cc7e 100644
--- a/frontend/src/i18n/pl.json
+++ b/frontend/src/i18n/pl.json
@@ -132,7 +132,6 @@
"Storage quota exceeded": "Przekroczono limit przestrzeni",
"File size limit exceeded": "Przekroczono limit rozmiaru pliku",
"The trash is read-only": "Kosz jest tylko do odczytu",
- "Storage quota will be exceeded": "Limit przestrzeni zostanie przekroczony",
"Access to internal IP addresses is forbidden": "Dostęp do wewnętrznych adresów IP jest zabroniony",
"Missing or invalid \"content-length\" header": "Brakujący lub nieprawidłowy nagłówek \"content-length\"",
"Maximum redirects exceeded": "Przekroczono maksymalną liczbę przekierowań",
diff --git a/frontend/src/i18n/pt-BR.json b/frontend/src/i18n/pt-BR.json
index 50d11077..92555f07 100644
--- a/frontend/src/i18n/pt-BR.json
+++ b/frontend/src/i18n/pt-BR.json
@@ -132,7 +132,6 @@
"Storage quota exceeded": "Cota de armazenamento excedida",
"File size limit exceeded": "Limite de tamanho do arquivo excedido",
"The trash is read-only": "A lixeira é somente leitura",
- "Storage quota will be exceeded": "A cota de armazenamento será excedida",
"Access to internal IP addresses is forbidden": "O acesso a endereços IP internos é proibido",
"Missing or invalid \"content-length\" header": "Cabeçalho \"content-length\" ausente ou inválido",
"Maximum redirects exceeded": "Número máximo de redirecionamentos excedido",
diff --git a/frontend/src/i18n/pt.json b/frontend/src/i18n/pt.json
index 05a9abb5..31f72521 100644
--- a/frontend/src/i18n/pt.json
+++ b/frontend/src/i18n/pt.json
@@ -132,7 +132,6 @@
"Storage quota exceeded": "A cota de armazenamento foi excedida",
"File size limit exceeded": "Limite de tamanho do ficheiro excedido",
"The trash is read-only": "A lixeira é apenas de leitura",
- "Storage quota will be exceeded": "A cota de armazenamento será excedida",
"Access to internal IP addresses is forbidden": "O acesso a endereços IP internos é proibido",
"Missing or invalid \"content-length\" header": "Cabeçalho \"content-length\" em falta ou inválido",
"Maximum redirects exceeded": "Número máximo de redirecionamentos excedido",
diff --git a/frontend/src/i18n/ru.json b/frontend/src/i18n/ru.json
index 9d05e36b..58f9cff6 100644
--- a/frontend/src/i18n/ru.json
+++ b/frontend/src/i18n/ru.json
@@ -132,7 +132,6 @@
"Storage quota exceeded": "Превышена квота хранилища",
"File size limit exceeded": "Превышен лимит размера файла",
"The trash is read-only": "Корзина доступна только для чтения",
- "Storage quota will be exceeded": "Квота хранилища будет превышена",
"Access to internal IP addresses is forbidden": "Доступ к внутренним IP-адресам запрещён",
"Missing or invalid \"content-length\" header": "Заголовок \"content-length\" отсутствует или недействителен",
"Maximum redirects exceeded": "Превышено максимальное число перенаправлений",
diff --git a/frontend/src/i18n/tr.json b/frontend/src/i18n/tr.json
index 20f2e652..17cdd882 100644
--- a/frontend/src/i18n/tr.json
+++ b/frontend/src/i18n/tr.json
@@ -132,7 +132,6 @@
"Storage quota exceeded": "Depolama kotası aşıldı",
"File size limit exceeded": "Dosya boyutu sınırı aşıldı",
"The trash is read-only": "Çöp kutusu salt okunurdur",
- "Storage quota will be exceeded": "Depolama kotası aşılacak",
"Access to internal IP addresses is forbidden": "Dahili IP adreslerine erişim yasaktır",
"Missing or invalid \"content-length\" header": "\"content-length\" başlığı eksik veya geçersiz",
"Maximum redirects exceeded": "Maksimum yönlendirme sayısı aşıldı",
diff --git a/frontend/src/i18n/zh.json b/frontend/src/i18n/zh.json
index 8424e3a7..b7612885 100644
--- a/frontend/src/i18n/zh.json
+++ b/frontend/src/i18n/zh.json
@@ -132,7 +132,6 @@
"Storage quota exceeded": "存储配额已超出",
"File size limit exceeded": "已超出文件大小限制",
"The trash is read-only": "回收站是只读的",
- "Storage quota will be exceeded": "存储配额将被超出",
"Access to internal IP addresses is forbidden": "禁止访问内部 IP 地址",
"Missing or invalid \"content-length\" header": "缺少或无效的 \"content-length\" 标头",
"Maximum redirects exceeded": "已超出最大重定向次数",