1

First, everything looked OK until yesterday (Mar 12, 2014). Since about lunch time, files (not folders) created by GDAA are not showing in the Web Drive interface anymore. A few showed up with a considerable delay (3+ hours) and nothing since. The Android GDAA find/search facility shows both the files (including contents) and folders, but the Web Drive has only folders. I use this code to test it, but I've tried the official demo as well with the same result.

seanpj
  • 6,735
  • 2
  • 33
  • 54
  • Is there any relevant logs you can provide? Do other modifications (other than folder creations) make it to the server? – Cheryl Simon Mar 13 '14 at 17:47
  • Unfortunately not, everything looks cool on the Android side. Just nothing's showing "up there". And I use Drive.DriveApi.requestSync() quite frequently. Let me play with it a bit more and I'll let you know when I pinpoint something. – seanpj Mar 13 '14 at 18:36
  • @CherylSimon, I have the answer. I went to my Android's device Settings and cleared cache+data of Google Play Services. Everything's cool now (except for all the garbage since yesterday - it was apparently stuck in cache). I'll wait for a while and put this as an answer. Is it something Google Play Services people should know about? I'm still puzzled who's taking care of what. – seanpj Mar 13 '14 at 20:34
  • There must be a bug in there somewhere that caused it to get stuck. If you are able to reproduce it, please post again. – Cheryl Simon Mar 13 '14 at 20:41
  • @CherylSimon Let's not get hung up on random problems if they don't come back. Considering how I abuse the the GooPlaySvcs, it is a surprise it doesn't happen daily. It is just a 'heads-up' for others if it ever happens to somebody else. I have another issue though, that keeps coming back. First discussed here (https://github.com/googledrive/android-demos/issues/3), it still persists. Should I analyze it again and open SO question on it? Or will it go away when you guys implement 'delete' in GDAA? It doesn't bother me and nobody else's complaining. – seanpj Mar 14 '14 at 02:28
  • @CherylSimon, if you watch this, I added continuation to the answer below (more another question that an answer). – seanpj Mar 17 '14 at 15:03

1 Answers1

2

Fixed by emptying the Google Play Services cache using standard Android device

Settings -> Apps -> Google Play Services -> Clear Cache

probably a snag caused by a development environment abuse of the services. Will investigate further if it reappears.

... continued

As I was digging deeper, I have discovered a quirk that looks like a non-issue, but can create a big problem for app developers.

1/ lets assume that user can go to device's

Settings -> Apps -> Google Play Services -> Manage Space -> Clear All Data

anytime she/he decides to. The app that uses GDAA has no knowledge of this action, and the device owner has no idea that Google Play Services has anything to do with Google Drive based app.

2/ The moment this happens the GDAA app loses it's ability to find folders / files by TITLE. Queries fail here (see "NO md AVAILABLE")

...
if (rslt.getStatus().isSuccess()) {
  MetadataBuffer mdb = null;
  try { 
    mdb = rslt.getMetadataBuffer();
    if (mdb == null) return null;
    dMDs = new ArrayList<DrvMD>();
    for (Metadata md : mdb) {
      if ((md == null) || (!md.isDataValid()) || (md.isTrashed())) continue;
      // NO md AVAILABLE !!! 
    }
  } finally { if (mdb != null) mdb.close(); } 
}

Even though it looks like a minor quirk, the fact that user can do this freely, causes MAJOR problem to the apps.

Here's why: Creating a folder/file in Google Drive will NOT fail if one with the same name exists. It will create a new one with the same name (and I understand the model). But if there is no reliable way to query for existence by name (caused by the user's action above), the app fails in this logic:

   if (FOLDER/FILE by name exists)
    return FOLDER/FILE ID
   else
     ID = create a new FOLDER/FILE

And so far this is the only logic I can come up when creating/accessing folder/file. I know there are 2 more unique IDs available (resource ID and DriveId), but they are not useful in this situation. Any ideas how to get around this? It would be nice if Google Play Services recovered from user's action without losing it's ability to query existing objects.

seanpj
  • 6,735
  • 2
  • 33
  • 54
  • It should recover eventually. After you clear the data, the next time you use the API (or picker) the drive data will be "reinstalled". Once that is done, you should see all the same data. If you care about the data, do a "requestSync" and wait for that to finish before doing your query. – Cheryl Simon Mar 18 '14 at 17:43
  • well Drive API for Android (at this point in time) certainly isn't behaving as "intended" (assuming the documentation + important missing information filled in by the community accurately covers those intentions). Same app, with same APP_ID, on 2 different devices is not able to find a common folder (rather one app will fail to find, and make its own version of the folder). Clearing Google Play Services cache isn't helping. Trashing the 2nd instance of the folder doesn't help, and even with a requestSync the device sees that folder as isTrashed=false (so that's not even accurate). BAD API, BAD – straya Aug 31 '15 at 01:52
  • @straya make sure you use ResourceId, NOT DriveID when using different devices. DriveId is valid only on one instance of GooPlaySvcs. i.e. on a single device. Even there, it changes during the lifespan of the Drive object (different before ResourceId comes [back](http://stackoverflow.com/questions/22874657/unpredictable-result-of-driveid-getresourceid-in-google-drive-android-api/31553269#31553269) in the 'onCompletion(even)) – seanpj Aug 31 '15 at 12:50
  • @seanpj I'm only using DriveIds once a folder/file is found (by matching title text) or created, so that means DriveIds aren't shared between devices rather the title of folders/files is. I.e. DriveIds local to a device are only used by that device and they are retrieved 'fresh' every time. It's the query calls which are not returning a set of folders/files that includes those created by a different device running same app sharing same APP_ID, so the text searches fail to find a match...and requestSync isn't helping on that front. – straya Sep 01 '15 at 01:51
  • First, look [here](http://stackoverflow.com/questions/32318859/google-drive-api-folder-child-id/32322360#32322360) to get more insight on it Second, If you're relying on the TITLE (file/folder name), you're asking for trouble. It is metadata in the GooDrive universe, so you may have MULTIPLE files/folder with the same title in the same Drive area (folder, for instance). And believe me, sooner or later you will. The only UNIQUE identifier is the ResourceId (aka 'id' in the REST Api). – seanpj Sep 01 '15 at 02:09