odeke-em / drive

Google Drive client for the commandline
Apache License 2.0
6.68k stars 427 forks source link

Failing to properly fetch google docs #306

Closed pefoley2 closed 9 years ago

pefoley2 commented 9 years ago

I have some google docs in my drive that are owned by other users in my google apps organization. (The folder is shared with an group, and they created a gdoc in it) After pr #305, I get output like this: Resolving...

/usr/backup/path/document.desktop exists and contains: [Desktop Entry] Icon=application-vnd.google-apps.document Name=document Type=Link URL=https://docs.google.com/a/example.com/document/d/.../edit?usp=drivesdk

odeke-em commented 9 years ago

I don't think that's an error. Take a look at the files reported. One is suffixed by *.desktop and the other isn't suffixed, it is Google Doc that isn't yet present locally by the time ChTime is run. This didn't fail to fetch the files but rather exposed an ignored error. Please let me know what you think.

odeke-em commented 9 years ago

Typing on my mobile phone is trippy. I'll respond better when am in front of my computer.

pefoley2 commented 9 years ago

If I delete the .desktop file, and run drive pull again, it re-creates it.

pefoley2 commented 9 years ago

This seems to actually apply to google docs that I create myself

odeke-em commented 9 years ago

Am back at my computer. So, this issue has nothing to do with PR #305 nor failure to properly fetch Google Docs. Actually what is happening is that because you are on Linux, due to the fact that we'd like clickable *.desktop files, the raw path is affixed by .desktop, however in the Chtime operation right after a download is performed, the raw path is used as was previously. Please note that Google Docs + Sheets can never be actually downloaded but only exported or the respective desktop file created. The README talks about this.

Here is where that error message that was exposed by PR 305 is:

diff --git a/src/pull.go b/src/pull.go
index 2e8e30a..3dc20db 100644
--- a/src/pull.go
+++ b/src/pull.go
@@ -413,7 +413,7 @@ func (g *Commands) localMod(wg *sync.WaitGroup, change *Change, exports [
                }
                downloadPerformed = true
        }
-       err = os.Chtimes(destAbsPath, change.Src.ModTime, change.Src.ModTime)
+       -> err = os.Chtimes(destAbsPath, change.Src.ModTime, change.Src.ModTime)

        // Update progress for the case in which you are only Chtime-ing
        // since progress for downloaded files is already handled separately

The bug here is the correlation between the doc and its alias (*.desktop) on Linux. I am pushing a PR to fix this. Thank you for the patience.

odeke-em commented 9 years ago

Thank you @pefoley2 for reporting this. Fixed by https://github.com/odeke-em/drive/pull/307. Cheers!