How to configure path length limit for IOUtils

90 views
Skip to first unread message

Matthew van der Hoorn

unread,
Jan 18, 2025, 5:30:10 PMJan 18
to zotero-dev
Hi everyone,

I am working on fixing an annoying bug for the ZotMoov plugin, namely that on Windows the IOUtils.move() function fails for any path with a length of over 260 characters. It doesn't throw an error, it simply fails to function, so it was a pain to even find out the cause.

I know this is the default length limit for Windows... However, on my machine I enabled Long Paths AND I am not even moving to a Windows system, but to my Synology NAS DS423, which is on a Linux OS, thus supporting up to 4k characters.

I am looking for a way to either:
A) Configure IOUtils/Zotero to respect this custom path length limit
B) An alternative to this function to achieve what we want.

For context, here is the line that needs to work:
```js
await IOUtils.copy(file_path, final_path, { noOverwrite: true });
```

This is my current quick fix, but it's hacky and not robust... Let alone ideal:
```js
            // Temporary fix for file path issue
            if (final_path.length > 260) {
                this.zotmoov_debugger.error("File path too long: " + final_path + "\nTotal " + (final_path.length) + " characters");
                this.zotmoov_debugger.debug("Implementing temporary fix; renaming file to paper.pdf");

                const original_file_name = PathUtils.filename(file_path);
                const new_file_name = 'paper.pdf';

                final_path = final_path.replace(original_file_name, new_file_name);

                if (final_path.length > 260) {
                    this.zotmoov_debugger.error("File path too long after temporary fix: " + final_path + "\nTotal " + (final_path.length) + " characters\nSKIPPING!");
                    return;
                }

                this.zotmoov_debugger.debug("Final path: " + final_path);
            }
```

Warm regards,
Mr. Hoorn

Dan Stillman

unread,
Jan 19, 2025, 7:49:00 AMJan 19
It doesn't sound like this can be safely enabled for a Mozilla app at
this time:

https://bugzilla.mozilla.org/show_bug.cgi?id=1910527#c3

You're welcome to try to make a custom Zotero build for your own
purposes, but I don't see us doing anything different from Mozilla here.
If Mozilla ends up enabling this, we'll do the same at that time. For
now, it doesn't sound like even Microsoft is seriously committed to
improving this situation.

(And to be clear, the OS of your Synology isn't relevant. This is
entirely about Windows.)

- Dan

Matthew van der Hoorn

unread,
Jan 19, 2025, 10:26:12 AMJan 19
to zotero-dev
Why is that irrelevant if the files get stored on the Synology and not Windows, that doesn't make sense at all to me, lol.

Dan Stillman

unread,
Jan 19, 2025, 10:30:19 AMJan 19
On 1/19/25 2:26 AM, Matthew van der Hoorn wrote:
> Why is that irrelevant if the files get stored on the Synology and not
> Windows, that doesn't make sense at all to me, lol.

Because the limitation is in the Windows API, not the filesystem.

https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation

(Please skip things like "lol" if you're going to post here.)
Reply all
Reply to author
Forward
0 new messages