waterbutler icon indicating copy to clipboard operation
waterbutler copied to clipboard

[SVCS-234][SVCS-21][SVCS-273] Fix resolve_to_ids to better disambiguate paths, extensions etc.

Open Johnetordoff opened this issue 7 years ago • 0 comments

Purpose

This arose out of the confluence of three tickets:

  1. Support slashes in google drive file names
  2. Google Docs (and spreadsheets, presentations) are accessible w/ and w/o extension
  3. Some read-only GDocs on GoogleDrive show up as 'Not Found'

After trying to resolve each individually I decided they had to be fixed together within the same function. Since Gdrive doesn't really use a file tree structure, we have to do some detective work to disambiguate the path we are given. There are many edge cases and tricky situations, but this should solve the solvable ones. Here are the two basic problems with passing only a path to GDrive.

  1. The extension problem: Files which are unique to Gdrive (gdocs, gsheets, ext) can have the same name so for example a gdoc and gsheet can both be called "Test" with no extension. So in order to tell the difference between these files we require the user to add supply an extension (Test.gdoc for gdocs, Test.gsheet for gsheets, etc.) We use the mimeType in the metadata to pick out the correct file. There are exceptions to this rule, if the user doesn't have permission to download the file they can't use the extension.

  2. The slash problem: When we get the path, we divide it into parts by splitting the path by the '/' characters. Example: 1/2/3 is split into parts "1", "2", "3", but this creates a problem if a file contains a '/', Example 1/2/3 is actually "1", "2/3". We resolve this problem by assuming there are no folders slashes in them, so any time a folder.

Changes

Added utility functions for sorting json response items, reworked resolve_to_ids function to better parse path and find files by extension fixed tests and added comments.

Side Effects

Everything works aside from '/' containing folder names.

Tickets / PRs

  1. Support slashes in google drive file names

  2. Google Docs (and spreadsheets, presentations) are accessible w/ and w/o extension PR: #195

  3. Some read-only GDocs on GoogleDrive show up as 'Not Found'

  4. Google Drive .g files of the same name do not display correctly Found this one after I put in this PR should be closable if this goes through.

Johnetordoff avatar Apr 11 '17 14:04 Johnetordoff