Fix File Length Limit IOUtils
IOUtils copy behavior fails on Windows with path lengths over 260 characters even though Long Paths is enabled in Windows Registry AND I am copying to a Linux Device (Synology DS423 NAS) which allows up to 4k characters.
I am looking for a way to configure either Zotero or IOUtils to respect a custom char length limit because keeping to 260 is silly when you can configure it on the OS.
Thanks in advance.
I am looking for a way to configure either Zotero or IOUtils to respect a custom char length limit because keeping to 260 is silly when you can configure it on the OS.
Thanks in advance.
This discussion has been closed.
However, there isn't an explicit error... The plugin just fails to do what it's supposed to do over 260 characters (literally does nothing, without dropping an error), and from what I read on the Mozilla forums, there is a way to configure the path length limit in the mozilla startup variables, and I assume this is something that Zotero has control over... Hence why I am putting it here instead of the obnoxious mozilla forums.
My "quick fix" is this:
```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);
}
```
But obviously this is undesired and not robust enough. (Yes, this does give me the supposed logs obviously, but out of the bat IOUtils/Zotero doesn't give me an error when doing the move function, it simply doesn't do anything)....
This is the actual line of code that I want working:
```js
await IOUtils.copy(file_path, final_path, { noOverwrite: true });
```
If you're a Zotero plugin developer, or are contributing to a plugin, post to zotero-dev and make that clear. These forums aren't the place for technical discussions, and certainly not ones without any context.
In any case, it doesn't sound like this can be safely enabled for a Mozilla app at this time. (You shouldn't ever post anything related to Zotero in Mozilla channels. It doesn't matter whether you think it's our problem or theirs.)