GPack
GPack

Reputation: 2504

Google Drive Android Api and Drive sync time

I am introducing in Google Drive Android Api as docs and examples show.
I created two activities which extend BaseDemoActivity of the example: the first one adds empty files to Drive customizing on each file some CustomProperties, the second one lists from Drive the files added grabbing the owned CustomProperties of each file.

first activity - code which adds files like this:

DriveFolder folder = Drive.DriveApi.getFolder(getGoogleApiClient(),
        mFolderDriveId);

CustomPropertyKey customPropertyKeyExample = new CustomPropertyKey(
        "custom", CustomPropertyKey.PRIVATE);

MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
        .setTitle("New empty file")
        .setMimeType("text/plain")
        .setCustomProperty(customPropertyKeyExample, "xyz")
        .build();

folder.createFile(getGoogleApiClient(), changeSet, null)
        .setResultCallback(fileCallback);

second activity - code which reads properties like this:

for (Iterator<Metadata> i = result.getMetadataBuffer().iterator(); i
        .hasNext();) {
        Metadata mChildren = ((Metadata) i.next());
        if (!mChildren.isTrashed()) {
            Map<CustomPropertyKey, String> mapProperties = mChildren
                .getCustomProperties();
            if (mapProperties.get(customPropertyKeyExample) == null) 
                // THIS TEST RETURNS TRUE UNTIL DRIVE SYNC EXECUTES
            }
        }
}

Them work, but i notice that the second activity, the list activity, must wait a Drive variable sync time to have the CustomProperties available.

Is there a way to get the CustomProperties from an activity immediately after them added by a different activity?

Upvotes: 0

Views: 410

Answers (1)

Daniel
Daniel

Reputation: 1309

This isn't expected behavior. Custom file properties should be available locally without performing a sync.

I've created a bug on our issue tracker to discuss this further: https://code.google.com/a/google.com/p/apps-api-issues/issues/detail?id=3848

Could you please respond on the bug, answering the following question:

  1. Can you verify that the title is also changed immediately?
  2. Which example class specifically are you using for your first and second activity?
  3. How are you sharing the DriveId for the folder between the activities?
  4. Are you using DriveFolder#listChildren or another query to get [result] in the second example?

Upvotes: 1

Related Questions