I've been trying to figure out what I'm doing wrong or if it's the intended behaviour. I am creating an app that uploads files to the Google Drive using Google Play Services Drive API. Before I create the parent folder I check if the folder already exists. For testing I delete the folder, then check in the app, however the app always detects that the folder is still there.
I have checked isTrashed on the MetaDataBuffer and it's always reported as false.
Is this a syncing issue between app and drive server?
This is the query that I use:
new Query.Builder().addFilter(
Filters.and(
Filters.eq(SearchableField.TRASHED, false),
Filters.eq(SearchableField.MIME_TYPE, MIME_TYPE_FOLDER),
Filters.eq(SearchableField.TITLE, name)
)).build();
Welcome to the club :-). This issue is one of the known quirks (pardon, features) of GDAA discussed all over the place. What you see is the side-effect of having a 'buffering' layer between your app and GooDrive. When placing any GDAA related request, you're talking to GooPlaySvcs layer, that has no clue what other apps (http://drive.google.com) did to the Drive. So many weird things can happen, like for instance:
1/ create a folder with your app
2/ trash and permanently delete that folder using http://drive.google.com
3/ let your app create a file in that folder - no indication of failure, file is created in a folder somewhere in Google never-never-land
If you really need to know the current Drive status, you have to poll the Drive using the REST Api.
Another option to keep it under control is to write your folder/files into an appfolder, making them inaccessible to other apps. Then, not even you can delete a file 'from behind'. Be careful, though, there is a related problem/issue with the appfolder you can run into when testing.
Good Luck