Milad Rezazadeh
Milad Rezazadeh

Reputation: 1483

Google drive API delete file updates the last modified date

There is a different behavior from Google Drive UI and Google Drive API, when removing a file.

Using Google Drive UI:

remove a file, it will go to trash folder and the Last Modified Date is still the same. (if user restore the file, still there is no change on last modified date)

Using Google Drive API:

delete a file, it will go to trash folder, BUT the Last Modified date is changed and if user restore the file, there will be a new modified date.

to me API behavior is more correct, because there is an action made to the file, therefore modified date should change, but how come Google UI doesn't change the Last Modified date ?

Thanks,

Upvotes: 0

Views: 783

Answers (1)

Eric Koleda
Eric Koleda

Reputation: 12673

This does appear to be an inconsistency between the UI and the API, although what the correct behavior should be is debatable. I've reached out the engineering team to see if they can bring the two paths inline. In the meantime, you can trash a file without changing the modifiedDate by instead using a Files.patch() request and setting the modifiedDateBehavior parameter to "noChange":

PATCH https://www.googleapis.com/drive/v2/files/...?modifiedDateBehavior=noChange

{
 "labels": {
  "trashed": true
 }
}

Upvotes: 2

Related Questions