From 8b8449ecb2661a95a15924c2a5c36728c8f51672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mindaugas=20Dirgin=C4=8Dius?= <25615181+mindaugasdirg@users.noreply.github.com> Date: Mon, 4 Dec 2023 17:42:58 +0200 Subject: [PATCH] Add fix to handle max path limit in windows (#130) Windows has a max total path limit of 260 and there can be schemas which don't reach the max path segment size, but the full path reaches max total path limit in windows systems. --- 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..10677d4b 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 260 + 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 // You'd have to be past 2**53-1 (Number.MAX_SAFE_INTEGER) long named schemas in order to hit decimal formatting,