Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shorten long filenames on import #104

Open
dstillman opened this issue Apr 28, 2012 · 5 comments
Open

Shorten long filenames on import #104

dstillman opened this issue Apr 28, 2012 · 5 comments

Comments

@dstillman
Copy link
Member

e.g. http://forums.zotero.org/discussion/23079

@dstillman
Copy link
Member Author

Still an issue for non-snapshot attachments, and apparently long filenames fail silently.

http://forums.zotero.org/discussion/27122/

@aurimasv
Copy link
Contributor

Here's a quick thought. Instead of using copyTo directly (in a lot of places), could we use Zotero.File.copyToUnique wherever we need to copy files? (similar idea for creating file) copyToUnique uses nsIFile.createUnique, which (A) creates unique file names, so that there's no chance of overwriting and (B) also shortens file names (without truncating the extension). This would certainly be better implemented than the truncateFileName function that I wrote.

We would need to modify copyToUnique to return either newName or newFile.append(newName) so that we can retrieve the new path. This should be safe, since copyToUnique does not appear to be used anywhere ATM.

Thoughts?

@dstillman
Copy link
Member Author

If nsIFile.createUnique really shortens long filenames that would otherwise trigger errors, this sounds good to me.

Returning the new nsIFile sounds good. I don't know why that returns the original nsIFile now.

dstillman added a commit that referenced this issue Apr 17, 2013
This fixes the problem for attached files. I assume this is still a
problem for importSnapshotFromFile(), which uses copyTo() on a
directory. For that we'd need a copyDirectoryToUnique() function that
shortened the names of all files in the directory.
@dstillman
Copy link
Member Author

@aurimasv: Good find on createUnique(). This seems to work perfectly.

@aurimasv
Copy link
Contributor

I was going to test if the shortening works correctly when the supplied file path is URI encoded. I expect that it should work fine, but if it's not, then there's a small chance that an encoded character gets split. I'll check some time later today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants