I am trying to overwrite the same file by saving a jpg, but it doesn’t seem to work even though file is opened with overwrite: true set.
Having a Folder, I create a file with overwrite: true and save my image as jpg into that file.
Then change the quality of jpg compression and save again, but the file doesn’t update anymore.
I have also tried creating a new File instance once again with the same name, but it also doesn’t update the file.
@kerrishotts I’ll try. My code at the moment is much more elaborate than the snippet.
This works first time, but if I call export function again with different quality data is never written to the file.
Ask user to select a folder, this gives folderEntry with access.
I have also tried re-creating the file in the folder with overwrite: true and re-creating session token before trying to export again – same thing, data is not updated.
If after export I call await file.getMetadata() I can see that bytes didn’t change even though with lower quality there should be less data written into the file
I have also tried deleting the file. Here it gets even more funny.
I have a permission to folderEntry where I have created file.
If I call await file.delete() file gets deleted, but I can see an error that FileSystemProvider: You don't have permission on this file 'Test_14.jpg'.
If right after this I try to create the file again it seems to get created and I see a new file descriptor, I create a new token and call my export function. But export descriptor fails with error Error: no such file or directory
@kerrishotts
I have also tried using temporary folder and create a file there. Same problem, writing to the file again or even re-creating the file to overwrite doesn’t update file contents anymore
I have also tried creating a file in temporary folder and then deleting it but I get the same exception FileSystemProvider: You don't have permission on this file
It looks like one of the main problems is that awaiting for the save descriptor doesn’t guarantee that saving actually completed writing data into filesystem.
So calling file.getMetadata() right after saving results in No such file or directly because even though Entry was created, file was not yet saved properly so there is no file yet.
Has anyone found a workaround for the FileSystemProvider: You don't have permission on this file error?
I’m trying to delete a file that was created by a previous run of my plugin, and then rename a new file to that name.
I get this error also when ‘await entry.delete()’ is executed before saving the new file, so I don’t believe it’s caused by the save operation running in the background.
Other files returned by getEntries are deleted without this error and after the save command.
Also, I discovered that if I moved the delete operation for other files ahead of the save operation for the new file, LFS deleted all of the files without throwing the error “FileSystemProvider: You don’t have permission on this file”.
I’m unclear as to the reason the sequence of deleting unrelated files is important.
I’d still like to use fs to save a log file to the same directory as the new TIF.
Based on the examples here:
Fs requires double backlashes instead of single forward slashes on a Mac, like this:
file:c:\path\to\allowed\file.json
Which of these functions will return a string with double slashes on a Mac?
anEntry.nativePath
homedir()
document.path
And will they be the required back slashes, or will the slashes have to be reversed, like on a PC?