Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1697,4 +1697,4 @@ EXAMPLES

# Current Limitations

- We currently have a 40GB size upload limitation per file for both, CLI and WebDAV
- Upload size limits depend on the account's plan tier. Since the CLI is only available to Ultimate plan users, we currently have a 100GB size upload limitation per file for both, CLI and WebDAV
2 changes: 1 addition & 1 deletion WEBDAV.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ No plain data is being sent or is being pulled from the Internxt servers, you ca

![image](https://raw.githubusercontent.com/internxt/cli/main/public/webdav-how-it-works.png)

_We currently have a 40GB size upload limitation per file for both, CLI and WebDAV_
_Upload size limits depend on the account's plan tier. Since the CLI is only available to Ultimate plan users, we currently have a 100GB size upload limitation per file for both, CLI and WebDAV_

## Officially supported WebDav clients

Expand Down
84 changes: 48 additions & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
"@inquirer/prompts": "8.5.2",
"@internxt/inxt-js": "3.3.5",
"@internxt/lib": "1.5.2",
"@internxt/sdk": "1.19.0",
"@internxt/sdk": "1.20.1",
"@oclif/core": "4.13.3",
"@oclif/plugin-autocomplete": "3.2.55",
"@oclif/plugin-autocomplete": "3.2.56",
"axios": "1.19.0",
"better-sqlite3": "12.11.1",
"bip39": "3.1.0",
Expand All @@ -52,11 +52,11 @@
"dotenv": "17.4.2",
"express": "5.2.1",
"express-async-handler": "1.2.0",
"fast-xml-builder": "1.3.0",
"fast-xml-builder": "1.3.1",
"fast-xml-parser": "5.10.1",
"hash-wasm": "4.12.0",
"mime-types": "3.0.2",
"open": "11.0.0",
"open": "11.0.1",
"openpgp": "6.3.1",
"otpauth": "9.5.1",
"pm2": "7.0.3",
Expand All @@ -74,15 +74,15 @@
"@types/cli-progress": "^3.11.6",
"@types/express": "^5.0.6",
"@types/mime-types": "^3.0.1",
"@types/node": "^26.1.2",
"@types/node": "^26.2.0",
"@types/range-parser": "^1.2.7",
"@vitest/coverage-istanbul": "^4.1.10",
"@vitest/spy": "^4.1.10",
"eslint": "^10.8.0",
"eslint": "^10.8.1",
"husky": "^9.1.7",
"lint-staged": "^17.3.0",
"nodemon": "^3.1.14",
"oclif": "^4.23.29",
"oclif": "^4.23.30",
"prettier": "^3.9.6",
"rimraf": "^6.1.3",
"sql.js": "^1.14.1",
Expand Down
3 changes: 2 additions & 1 deletion src/services/database/drive-item/drive-item.model.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { DriveItemAttributes } from './drive-item.attributes';
import { Column, Entity, PrimaryColumn } from 'typeorm';
import { Column, Entity, Index, PrimaryColumn } from 'typeorm';

@Entity('drive_item')
export class DriveItemModel implements DriveItemAttributes {
@PrimaryColumn({ nullable: false, type: 'varchar' })
declare uuid: string;

@Index()
@Column({ nullable: false, type: 'varchar' })
declare path: string;

Expand Down
16 changes: 14 additions & 2 deletions src/services/database/drive-item/drive-item.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,27 @@ export class DriveItemRepository {
const existingByUuid = new Map(existing.map((e) => [e.uuid, e]));
const existingByPath = new Map(existing.map((e) => [e.path, e]));

const itemsToInsert: DriveItemModel[] = [];
const itemsToUpdate: { targetUuid: string; item: DriveItemModel }[] = [];

for (const item of items) {
const match = existingByUuid.get(item.uuid) ?? existingByPath.get(item.path);
if (match) {
await this.repository.update(match.uuid, item);
itemsToUpdate.push({ targetUuid: match.uuid, item });
} else {
await this.repository.insert(item);
itemsToInsert.push(item);
}
}

await this.repository.manager.transaction(async (transactionalEntityManager) => {
if (itemsToInsert.length > 0) {
await transactionalEntityManager.insert(DriveItemModel, itemsToInsert);
}
for (const { targetUuid, item } of itemsToUpdate) {
await transactionalEntityManager.update(DriveItemModel, targetUuid, item);
}
});

return items.map((item) => new DriveItemBD(item));
} catch (error) {
ErrorUtils.report(error, { createOrUpdate: items });
Expand Down
41 changes: 36 additions & 5 deletions src/webdav/middewares/errors.middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,43 @@ import { webdavLogger } from '../../utils/logger.utils';
import { XMLUtils } from '../../utils/xml.utils';
import { ErrorUtils } from '../../utils/errors.utils';

/**
* SDK errors (AxiosResponseError/AxiosUnknownError) carry the upstream API's response
* body in `data`, which is discarded unless we read it explicitly.
*/
const getErrorDetail = (err: unknown): string | undefined => {
if (typeof err !== 'object' || err === null || !('data' in err)) return undefined;

const data = (err as { data?: unknown }).data;
if (typeof data !== 'object' || data === null || !('message' in data)) return undefined;

const message = (data as { message?: unknown }).message;
if (typeof message === 'string' && message.trim().length > 0) return message;
if (Array.isArray(message) && message.length > 0) return message.join(', ');
return undefined;
};

/**
* The CLI's own errors (BadRequestError, NotFoundError, ...) expose `statusCode`,
* but errors normalized by @internxt/sdk's HttpClient expose `status` instead.
*/
const getErrorStatusCode = (err: unknown): number | undefined => {
if (typeof err !== 'object' || err === null) return undefined;

const { statusCode, status } = err as { statusCode?: unknown; status?: unknown };
if (typeof statusCode === 'number' && !Number.isNaN(statusCode)) return statusCode;
if (typeof status === 'number' && !Number.isNaN(status)) return status;
return undefined;
};

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const ErrorHandlingMiddleware: ErrorRequestHandler = (err, req, res, _) => {
const message = ErrorUtils.isError(err) ? err.message : 'Something went wrong';
let message = ErrorUtils.isError(err) ? err.message : 'Something went wrong';

const detail = getErrorDetail(err);
if (detail) {
message += ` [${detail}]`;
}

if (ErrorUtils.isError(err) && err.stack) {
webdavLogger.error(`[ERROR MIDDLEWARE] [${req.method.toUpperCase()} - ${req.url}] ${message}\nStack: ${err.stack}`);
Expand All @@ -21,10 +55,7 @@ export const ErrorHandlingMiddleware: ErrorRequestHandler = (err, req, res, _) =
'error',
);

let statusCode = 500;
if ('statusCode' in err && !Number.isNaN(err.statusCode)) {
statusCode = err.statusCode;
}
const statusCode = getErrorStatusCode(err) ?? 500;

res.set('Content-Type', 'application/xml; charset="utf-8"');
res.status(statusCode).send(errorBodyXML);
Expand Down
5 changes: 5 additions & 0 deletions test/services/network/network-facade.service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ describe('Network Facade Service', () => {
vi.spyOn(UsageService.instance, 'fetchLimits').mockResolvedValue({
maxUploadFileSize: null,
versioning: { enabled: false, maxFileSize: 0, retentionDays: 0, maxVersions: 0 },
photosAccess: false,
});

await sut.uploadFile({
Expand All @@ -73,6 +74,7 @@ describe('Network Facade Service', () => {
vi.spyOn(UsageService.instance, 'fetchLimits').mockResolvedValue({
maxUploadFileSize: 1024 * 1024,
versioning: { enabled: false, maxFileSize: 0, retentionDays: 0, maxVersions: 0 },
photosAccess: false,
});

await expect(() =>
Expand Down Expand Up @@ -101,6 +103,7 @@ describe('Network Facade Service', () => {
vi.spyOn(UsageService.instance, 'fetchLimits').mockResolvedValue({
maxUploadFileSize: null,
versioning: { enabled: false, maxFileSize: 0, retentionDays: 0, maxVersions: 0 },
photosAccess: false,
});

await expect(() =>
Expand Down Expand Up @@ -129,6 +132,7 @@ describe('Network Facade Service', () => {
vi.spyOn(UsageService.instance, 'fetchLimits').mockResolvedValue({
maxUploadFileSize: 1024 * 1024 * 1024,
versioning: { enabled: false, maxFileSize: 0, retentionDays: 0, maxVersions: 0 },
photosAccess: false,
});

await expect(() =>
Expand Down Expand Up @@ -157,6 +161,7 @@ describe('Network Facade Service', () => {
vi.spyOn(UsageService.instance, 'fetchLimits').mockResolvedValue({
maxUploadFileSize: 100 * 1024 * 1024,
versioning: { enabled: false, maxFileSize: 0, retentionDays: 0, maxVersions: 0 },
photosAccess: false,
});

await sut.uploadFile({
Expand Down
Loading
Loading