From 7d905d9f0327076382a12e083de2918e818dc6ae Mon Sep 17 00:00:00 2001 From: mindaugasdirg <25615181+mindaugasdirg@users.noreply.github.com> Date: Thu, 30 Nov 2023 16:21:59 +0200 Subject: [PATCH 1/3] Add fix to handle max path limit in windows --- packages/transformer/src/IModelTransformer.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/transformer/src/IModelTransformer.ts b/packages/transformer/src/IModelTransformer.ts index af5b349c..cd2514e5 100644 --- a/packages/transformer/src/IModelTransformer.ts +++ b/packages/transformer/src/IModelTransformer.ts @@ -2151,7 +2151,9 @@ export class IModelTransformer extends IModelExportHandler { let schemaFileName = schema.name + ext; // many file systems have a max file-name/path-segment size of 255, so we workaround that on all systems const systemMaxPathSegmentSize = 255; - if (schemaFileName.length > systemMaxPathSegmentSize) { + // windows usually has a limit for the total path length of 256 + const windowsMaxPathLimit = 256; + if (schemaFileName.length > systemMaxPathSegmentSize || path.join(this._schemaExportDir, schemaFileName).length >= windowsMaxPathLimit) { // this name should be well under 255 bytes // ( 100 + (Number.MAX_SAFE_INTEGER.toString().length = 16) + (ext.length = 13) ) = 129 which is less than 255 // You'd have to be past 2**53-1 (Number.MAX_SAFE_INTEGER) long named schemas in order to hit decimal formatting, From de068a8f99986515e7ac7aa7165eb19903f205da Mon Sep 17 00:00:00 2001 From: mindaugasdirg <25615181+mindaugasdirg@users.noreply.github.com> Date: Thu, 30 Nov 2023 16:24:00 +0200 Subject: [PATCH 2/3] Correct windows max path limit --- packages/transformer/src/IModelTransformer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/transformer/src/IModelTransformer.ts b/packages/transformer/src/IModelTransformer.ts index cd2514e5..d2023c71 100644 --- a/packages/transformer/src/IModelTransformer.ts +++ b/packages/transformer/src/IModelTransformer.ts @@ -2152,7 +2152,7 @@ export class IModelTransformer extends IModelExportHandler { // many file systems have a max file-name/path-segment size of 255, so we workaround that on all systems const systemMaxPathSegmentSize = 255; // windows usually has a limit for the total path length of 256 - const windowsMaxPathLimit = 256; + const windowsMaxPathLimit = 260; if (schemaFileName.length > systemMaxPathSegmentSize || path.join(this._schemaExportDir, schemaFileName).length >= windowsMaxPathLimit) { // this name should be well under 255 bytes // ( 100 + (Number.MAX_SAFE_INTEGER.toString().length = 16) + (ext.length = 13) ) = 129 which is less than 255 From 6e4047b4ed5484bed6d6afc6f2c5563fdf84f401 Mon Sep 17 00:00:00 2001 From: mindaugasdirg <25615181+mindaugasdirg@users.noreply.github.com> Date: Thu, 30 Nov 2023 17:33:57 +0200 Subject: [PATCH 3/3] Fix comment --- packages/transformer/src/IModelTransformer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/transformer/src/IModelTransformer.ts b/packages/transformer/src/IModelTransformer.ts index d2023c71..10677d4b 100644 --- a/packages/transformer/src/IModelTransformer.ts +++ b/packages/transformer/src/IModelTransformer.ts @@ -2151,7 +2151,7 @@ export class IModelTransformer extends IModelExportHandler { let schemaFileName = schema.name + ext; // many file systems have a max file-name/path-segment size of 255, so we workaround that on all systems const systemMaxPathSegmentSize = 255; - // windows usually has a limit for the total path length of 256 + // windows usually has a limit for the total path length of 260 const windowsMaxPathLimit = 260; if (schemaFileName.length > systemMaxPathSegmentSize || path.join(this._schemaExportDir, schemaFileName).length >= windowsMaxPathLimit) { // this name should be well under 255 bytes