ShellAnything Errors out when opening a context on Google Docs/Sheets/etc
hboyd2003 opened this issue · comments
Describe the bug
When right clicking on any Google Document (.gdocs/.gsheet/etc) a dialog opens up stating there was a problem opening the file. The dialog appears three times in total. After you close them all, the context menu opens normally including all of the ShellAnything entries.
To Reproduce
- Go to a mounted Google Drive drive
- Write click on any google document file (.gdocs/.gsheet/etc)
Expected behavior
Context menu opens without erring out.
Environment
- OS: Windows 11 22H2
- Version 0.07 & '0.08'
Additional context
- I was not able to test this outside of my Google Drive as windows copy does not work on these files either
- The log gives no warnings or errors to this error.
- The log states that the file is found (in direct contradiction to dialog)
- The error appears even when no ShellAnything entries are enabled (no .xml files)
Hi. Sorry for the late reply.
Congratulation for finding this and thank you for reporting it.
Shell anything tries to read the first bytes of the selected file to properly detect the file's mimetype. This is a new feature similar to Unix's file command. Base on this result, menus can be hidden or showed.
I think you are the first one to encounter and report this bug. I think this is because your selected file is open in your editor. The file cannot be read because it is locked by another process, probably from your file editor or the process who synchronize your directory/file with your Google drive.
If Shell anything encounter such error while trying to peak into a file, an error message should not be displayed. Shell anything should expect an "unknown" mimetype and continue with normal behavior.
I have other properties priorities (other issues) that I need to look for at this time. As soon as I am available, I will look at this. On a side note, I would gladly accept any help. If you would like to offer your help, I will accept a push request.
Thank you.
EDIT: Typos.
I created more unit tests in 54de08c to reproduce your issue with a "file lock" error. I was not able to reproduce your observation (I do not have a Google Drive). Even when the file is locked by the operating system, the magic library does not fail as you observed.
In my last commit, I have modified how ShellAnything deals with errors related to magic library. It is now logging errors to the error log file instead of showing a popup error message. This will solve the unexpected error prompt to users.
If you right-click on a locked file, ShellAnything now generates the following properties:
selection.mimetype=writable, executable, regular file, no read permission
selection.description=writable, executable, regular file, no read permission
selection.charset=writable, executable, regular file, no read permission
I am unable to find a fix for Spreadsheet files on Google Drive. These files may be "unreadable" similar to when a file is locked. If the magic library cannot read the file I think there are no workaround. The magic library needs to be able to read the beginning of a file to detect "what" the file is.
If you try to right-click on a file on your Goodle Drive, you should see an error in your log files. For example:
Failed to get mime type of file '<path>'. <magic-error-description>.
where <path>
is the actual path to your Google Drive spreadsheet and <magic-error-description>
is a more descriptive error provided by the magic library. If you do not consider the issue resolved, please open a new issue and specify the actual <path> that you see in your logs.
Fixed.