google / skicka

Command-line utility for working with Google Drive. Join the mailing list at https://groups.google.com/forum/#!forum/skicka-users.
Apache License 2.0
1.3k stars 119 forks source link

Set the modifiedDate property on upload #10

Closed agoode closed 9 years ago

agoode commented 10 years ago

You are setting the ModificationTime property on the file when uploading to Drive. But it would be nice if the native modifiedDate field were also set. This would allow the proper date/time to be reflected in the Drive GUI and other tools. Note that you'll also need to set the setModifiedDate parameter if you are updating an existing file.

It would be excellent if this functionality could be added to skicka and then applied to already uploaded files, since it is just a metadata change.

mmp commented 10 years ago

I believe that modifiedDate is already being set; with the following patch, if I run skicka -debug ls -ll /foo after an initial upload, modifiedDate has a reasonable value, and if I modify a file and upload again, modifiedDate seems to be updated appropriately (even without enabling setModifiedDate). What behavior are you seeing?

--- a/skicka.go
+++ b/skicka.go
@@ -2146,6 +2146,8 @@ func ls() {
                            prop.Value)
                    }
                    fmt.Printf("]\n")
+                                        fmt.Printf("\tDrive modification time: %v\n",
+                                           file.ModifiedDate)
                }
            } else {
                fmt.Printf("%s  %s  %s  %s\n", permString,
agoode commented 10 years ago

The value of the file in Drive doesn't match the original timestamp, but the server time when the file was inserted or updated. You need to explicitly add this field in createDriveFile: ModifiedDate: modTime.Format(time.RFC3339Nano), and then something similar in updateModificationTime.

If you are interested, I am working on a patch that I could probably send you tomorrow.

Also, I am curious why you have a custom property for this instead of using the ModifiedDate field directly?

agoode commented 10 years ago

The server is buggy and won't accept dates without fractional seconds. So instead of time.RFC3339Nano, you need a slight modification: "2006-01-02T15:04:05.000000000Z07:00" for the format.

mmp commented 10 years ago

A patch would be lovely!

To be honest, I hadn't realized that modifiedDate could be set manually via the Drive APIs; I had just assumed that it was set automatically based on the actual modification time and that was that. So I don't think there's an actual need for the metadata in this case, which is a nice simplification.

agoode commented 10 years ago

Pull request #11