dropbox / dropbox-sdk-python

The Official Dropbox API V2 SDK for Python
https://www.dropbox.com/developers
MIT License
930 stars 318 forks source link

files_search_v2 returns File Metadata with server_modified set to a random client_modified value #460

Closed jporcenaluk closed 9 months ago

jporcenaluk commented 1 year ago

Describe the bug When searching for files using the files_search_v2 function, the metadata for the files includes a repeated value for server_modified that is randomly retrieved from any one of the files' client_modified field values.

This makes it very difficult to know if a file needs to be downloaded, as client_modified is called out in the docs as not a reliable way to find that out, where server_modified is intended to be. Current functionality indicates that server_modified is not reliable for that purpose.

To Reproduce

  1. Upload two files to dropbox at different times
  2. Use files_search_v2 to retrieve files
  3. Print the client_modified and server_modified metadata on the files
  4. Observe that client_modified is different for each file, but server_modified is the same for each file (and is set to one or the other of the client_modified values)

Example Code

from datetime import datetime, timedelta
import pytz
import dropbox as dropbox
from dropbox.files import SearchOptions

data = {
  "dropboxFolder": "/a_folder",
  "ticketingToken": "abcd",
  "timeZone": "Europe/London"
}

dbx = dropbox.Dropbox(data["ticketingToken"])
time_zone = data["timeZone"]
dropbox_dir = data["dropboxFolder"]
datetime_now = datetime.now(tz=pytz.timezone(time_zone))
current_month_strftime = datetime_now.strftime("%Y %m")

files = dbx.files_search_v2(
        query=current_month_strftime, options=SearchOptions(path=dropbox_dir)
    ).matches

for idx, file in enumerate(files):
    file = file.metadata.get_metadata()
    print(f"file_{idx}"," - ", file.client_modified," - ", file.server_modified)

Expected Behavior Expected to see server_modified has different values per file that indicate when they were last modified.

Actual Behavior server_modified is the same value for each file, and randomly changes, and is aligned with one random client_modified value from what is returned from the search.

Screenshots

image

Versions

Additional context This is important to us, as we require a reliable way to identify new files being uploaded to Dropbox for our use case.

greg-db commented 1 year ago

Thanks for the report! We'll look into it and I'll follow up here once I have an update.

jporcenaluk commented 1 year ago

Thanks @greg-db ! I updated the ticket with example code that should work once the following dependencies are installed via pip:

dropbox
pytz
greg-db commented 9 months ago

Apologies for the delayed response. The team has reported that this was fixed. Please let us know if you're still seeing this.