修改日期在google drive API copy命令后更改

时间:2013-05-03 14:47:27

标签: android google-drive-api

我正在开发的Android应用与Google云端硬盘集成。我有一个功能来复制驱动器上的文件,我使用以下代码:

        File newFile = new File();
        newFile.setTitle(mItem.GetName());
        ParentReference newParent = new ParentReference();
        newParent.setId(gDriveFolder.getFileId());
        List<ParentReference> parents = new ArrayList<ParentReference>(1);
        parents.add(newParent);
        newFile.setParents(parents);
        File copiedFile = service.files().copy(mItem.getFileId(), newFile).execute();   
        String copiedFileId = copiedFile.getId();

        long copiedModDate = copiedFile.getModifiedDate().getValue();       
        Log.d("serverSideCopyMove", "File returned from copy command has modified date of " + copiedModDate);

        // bug here in google drive because the last mod date returned from the above 
        // gets changed a few micro-seconds later, thus the need to make a separate
        // server call to get new mod date again
        File getFile = service.files().get(copiedFileId).execute();
        copiedModDate = getFile.getModifiedDate().getValue(); //why different value?
        Log.d("serverSideCopyMove", "Separate call to get same copied file returns modified date of " + copiedModDate);
        // end of workaround

您将从我的代码中看到,复制命令返回的文件的修改日期与我在同一文件上执行'get'时的修改日期不同。我只是想知道这是一个错误还是我错误地使用了这些电话?

0 个答案:

没有答案