sreelal / google-api-objectivec-client

Automatically exported from code.google.com/p/google-api-objectivec-client
0 stars 0 forks source link

Deleting Files fails with assertion #19

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run the Drive Sample Application and attempt to delete a file after signing 
in

Expected results:
File is deleted and query callback occurs displaying an alert informing that 
the file has been deleted

Actual results:
File is deleted remotely and assertion occurs in the code:    GTL_ASSERT([json 
count] != 0, @"Creating object from empty json");

What version of the product are you using? build from 6-Aug-2012
On what operating system? OSX Lion

Apparently, the drive server used to return no data when deleting a file, but 
now it returns JSON with an empty results array.  This breaks the code.  

A fix is below:
in GTLService.m parseObjectyFromDataOfFetcher:

      //DEFECT WORKAROUND FOR GTLSERVICE - Google API now does return JSON data for deletes, but the JSON array for result is blank.  Check json count and ignore if empty
      if (json != nil && [json count]>0) {
...
      } else if (!isREST) {
        NSMutableDictionary *errorJSON = [jsonWrapper valueForKey:@"error"];
          //DEFECT WORKAROUND PART 2:  Don't assert on no error due to the situation described above.  
          if(errorJSON!=nil){
              GTL_DEBUG_ASSERT(errorJSON != nil, @"no result or error in response:\n%@",
                         jsonWrapper);
              GTLErrorObject *errorObject = [GTLErrorObject objectWithJSON:errorJSON];
              NSError *error = [errorObject foundationError];

              // Store the error and let it go to the callback
              [properties setValue:error
                      forKey:kFetcherFetchErrorKey];
          }
        }
    }

Original issue reported on code.google.com by joels...@gmail.com on 10 Sep 2012 at 10:20

GoogleCodeExporter commented 9 years ago
Thanks for reporting this issue. A fix was submitted on Sept 10.

https://code.google.com/p/google-api-objectivec-client/source/detail?r=207

Original comment by grobb...@google.com on 13 Sep 2012 at 9:56