Преглед на файлове

iOS: Fix file parsing in GDrive

All files were listed in the root view even the files in the folders.

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
Soomin Lee преди 8 години
родител
ревизия
f62a59ccc6
променени са 1 файла, в които са добавени 7 реда и са изтрити 9 реда
  1. 7 9
      Sources/VLCGoogleDriveController.m

+ 7 - 9
Sources/VLCGoogleDriveController.m

@@ -181,6 +181,7 @@
     _fileList = nil;
     _folderId = folderId;
     GTLQueryDrive *query;
+    NSString *parentName = @"root";
 
     query = [GTLQueryDrive queryForFilesList];
     query.pageToken = _nextPageToken;
@@ -189,9 +190,13 @@
     query.includeDeleted = NO;
     query.includeRemoved = NO;
     query.restrictToMyDrive = YES;
+    query.fields = @"files(*)";
+
     if (![_folderId isEqualToString:@""]) {
-        query.q = [NSString stringWithFormat:@"'%@' in parents", [_folderId lastPathComponent]];
+        parentName = [_folderId lastPathComponent];
     }
+    query.q = [NSString stringWithFormat:@"'%@' in parents", parentName];
+
     _fileListTicket = [self.driveService executeQuery:query
                           completionHandler:^(GTLServiceTicket *ticket,
                                               GTLDriveFileList *fileList,
@@ -255,16 +260,9 @@
 
     for (GTLDriveFile *iter in _fileList.files) {
         BOOL isDirectory = [iter.mimeType isEqualToString:@"application/vnd.google-apps.folder"];
-        BOOL inDirectory = NO;
-        if (iter.parents.count > 0) {
-            GTLDriveFile *parent = [iter.parents firstObject];
-            //since there is no rootfolder display the files right away
-            if (parent.parents == nil)
-                inDirectory = ![parent.identifier isEqualToString:[_folderId lastPathComponent]];
-        }
         BOOL supportedFile = [self _supportedFileExtension:iter.name];
 
-        if ((isDirectory || supportedFile) && !inDirectory)
+        if (isDirectory || supportedFile)
             [listOfGoodFilesAndFolders addObject:iter];
     }
     _currentFileList = [_currentFileList count] ? [_currentFileList arrayByAddingObjectsFromArray:listOfGoodFilesAndFolders] : [NSArray arrayWithArray:listOfGoodFilesAndFolders];