end2endzone / ShellAnything

ShellAnything is a C++ open-source software which allow one to easily customize and add new options to *Windows Explorer* context menu. Define specific actions when a user right-click on a file or a directory.
MIT License
180 stars 27 forks source link

ShellAnything Errors out when opening a context on Google Docs/Sheets/etc #121

Closed hboyd2003 closed 1 year ago

hboyd2003 commented 1 year ago

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

  1. Go to a mounted Google Drive drive
  2. Write click on any google document file (.gdocs/.gsheet/etc)

Expected behavior Context menu opens without erring out.

Screenshots The Error Dialog Photo of the error dialog

Environment

Additional context

end2endzone commented 1 year ago

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.

end2endzone commented 1 year ago

I created more unit tests in 54de08c5f333ffc2a341dee21dcbe9c9173afa57 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.

end2endzone commented 1 year ago

Fixed.