Skip to content
This repository has been archived by the owner on Sep 3, 2020. It is now read-only.

Fix bug with missing downloadURL for docs/sheets #25

Closed
wants to merge 21 commits into from

Conversation

odeke-em
Copy link
Contributor

Google Docs + Sheets do not populate 'DownloadUrl', but
instead provide an map of exportLinks ie csv, docx, pptx,
txt etc. Simple heuristic to determine the url to export
as well as create the target extension to avoid clobbering
of the original file on a re-sync.
This PR addresses issues #11, #31. It also potentially addresses #29 but the receipe will be fully complete once PR #32 or even better PR #39 gets merged.

@odeke-em odeke-em force-pushed the master branch 8 times, most recently from 51aebfa to 81cfdd9 Compare November 14, 2014 08:14
@rakyll
Copy link
Owner

rakyll commented Nov 20, 2014

Maybe we should touch an empty file locally for Docs files and prefer not to download the contents. We can easily detect the Docs files remotely and skip them during the upload. One consistency problem would arise if someone locally delete a Docs file and replace it with a regular one and runs a push.

Exporting is good to back things up, but I don't think that's the expected behavior for the majority of the users.

@odeke-em
Copy link
Contributor Author

Good idea. Sounds like a plan, however we shall need to inform the users in the README about the trips with Docs.

@odeke-em
Copy link
Contributor Author

@rakyll could this then become a feature ie exporting or creating backups and then retain the empty file creation for Doc files?

@rakyll
Copy link
Owner

rakyll commented Nov 21, 2014

There could be a separate command to backup the Docs file, and backing up should not support upstreaming.

@odeke-em
Copy link
Contributor Author

Aye aye, thanks for the clarification.

Emmanuel Odeke added 4 commits November 21, 2014 13:19
Adds the ability for one to go like this:
mkdir ~/drive
cd drive
drive init
...
drive pull Photos
cd Photos
drive push
drive publish Photos

refactoring: pull & push into changes
Emmanuel Odeke added 2 commits December 5, 2014 03:08
Google Docs + Sheets do not populate 'DownloadUrl', but
instead provide an map of exportLinks ie csv, docx, pptx,
txt etc. Simple heuristic to determine the url to export
as well as create the target extension to avoid clobbering
of the original file on a re-sync.
@odeke-em
Copy link
Contributor Author

odeke-em commented Dec 5, 2014

@rakyll, please see the latest.

// exportable type since we cannot directly download the raw data.
// We also need to pay attention and add the exported extension
// to avoid overriding the original file on re-syncing.
if len(change.Src.BlobAt) < 1 && exportOnBackup && IsGoogleDoc(change.Src) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this if be as simple as:

if hasExportLinks(change.Str) && export {

}

Why do we have to care about BlobAt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, see I am thinking about the case that a file has both exportLinks as well as BlobAt. In this case we would want to download the actual file.
Actually you are right, given that isGoogleDoc involves a check for BlobAt == "".

@odeke-em
Copy link
Contributor Author

odeke-em commented Dec 6, 2014

@rakyll, got the desired -exports fmt1,fmt2,fmt3 etc in, plus fixed a couple of the nits raised.

@odeke-em odeke-em force-pushed the master branch 6 times, most recently from 83f8b97 to 2a327f9 Compare December 6, 2014 06:24
@odeke-em odeke-em force-pushed the master branch 2 times, most recently from 6feb3ed to c83bc67 Compare December 6, 2014 10:33
Emmanuel Odeke added 2 commits December 18, 2014 18:27
This enables pushes from arbitrary paths e.g
`drive push -r /Volumes/SDCard ~/gdrive`
instead of always having to copy content first into the drive
then pushing it.
Basic idea is the creation of a symlink that gets cleared
on deferal.
@odeke-em
Copy link
Contributor Author

@rakyll ping!

@odeke-em odeke-em force-pushed the master branch 2 times, most recently from ba0e00e to 0aa17b4 Compare December 27, 2014 09:12
Allows for command like this:
`drive pull -export doc`
Equal to
`drive pull -export docx`
and any other similar formats bunched together
+ Moved duplicated code into one function.
+ Ensuring that exported docs have the correct paths.
@ikwyl6
Copy link

ikwyl6 commented Dec 29, 2014

Any idea when this could be implemented into master?

@odeke-em
Copy link
Contributor Author

Implemented in my fork: https://github.com/odeke-em/drive

@odeke-em odeke-em closed this Dec 31, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants