Search code examples
google-apigoogle-drive-apigoogle-api-client

Google drive modifiedTime changes after update response


I updated a file using the client API:

FilesResource.UpdateMediaUpload request;
request = Service.Files.Update(new Google.Apis.Drive.v3.Data.File(), id, stream);
request.Upload();

var Modified = request.ResponseBody.ModifiedTime;

I then requested for the same file after:

var modified = Service.Files.Get(id).Execute().ModifiedTime

These dates are milliseconds out of sync, i.e.:

modified.ticks = 636284845226980000

Modified.ticks = 636284845229162448

Modified.time - modified.time = 218ms

Why is this happening, and how can I rectify this?


Solution

  • It's happening because the file meta data is being updated asynchronously and there is nothing you can do to rectify it because it isn't a fault.

    If you explain why this causes you a problem, there may be an alternative approach. Eg:-

    1. Use the revisions feed
    2. Use the changes feed
    3. For non-Google files, you can use the md5sum
    4. If you are happy to use the v2 API, you can use etag
    5. Use the Properties feature to "tag" the file manually with an increment or timestamp