Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sometimes Parse doesn't fetch all objects of my Parse class (Images Downloading)

I download images from Parse, and sometimes the fetch result get more errores than images get. That's the code I use to download the images:

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{

    *PFQuery *query = [PFQuery queryWithClassName:albumToLoad];

    NSArray *objectsPFFounded=[NSArray arrayWithArray:[query findObjects]];

    int count= [objectsPFFounded count];

    int i=0;
    while (i<count){
        PFFile *userImageFile = [objectsPFFounded objectAtIndex:i][@"imageFile"];
        [userImageFile getDataInBackgroundWithBlock:^(NSData *imageData, NSError *error) {
            if (!error) {

                if (!self.imagesGallery) {
                    self.imagesGallery = [NSMutableArray arrayWithObject:[UIImage imageWithData:imageData]];
                }else{
                    [self.imagesGallery addObject:[UIImage imageWithData:imageData]];
                }

            }
        }];
        i++;
    }
    dispatch_async(dispatch_get_main_queue(), ^{
      [self updateCollectionViewWhenBackgroundDone];
        });
    });

I get as well this error from console:

    Could not save HTTP response body to /var/mobile/Applications/D96AFE9B-17EF-4630-8608-423D721394F3/Library/Caches/Parse/PFFileCache/578df836-a12c-4e70-b389-033efa647ee5-28.jpg: Error Domain=NSCocoaErrorDomain Code=516 "The operation couldn’t be completed. (Cocoa error 516.)" UserInfo=0x16ed58a0 {NSSourceFilePathErrorKey=/private/var/mobile/Applications/D96AFE9B-17EF-4630-8608-423D721394F3/tmp/PFHTTPCommand0x16ddd220, NSUserStringVariant=( Move ), 
NSFilePath=/private/var/mobile/Applications/D96AFE9B-17EF-4630-8608-423D721394F3/tmp/PFHTTPCommand0x16ddd220, NSDestinationFilePath=/var/mobile/Applications/D96AFE9B-17EF-4630-8608-423D721394F3/Library/Caches/Parse/PFFileCache/578df836-a12c-4e70-b389-033efa647ee5-28.jpg, NSUnderlyingError=0x16ee8350 "The operation couldn’t be completed. File exists"}

Have I to delete temp directory or cache directory before do the objects fetching? How can I solve this?

Thanks

like image 502
santibernaldo Avatar asked Jan 27 '26 13:01

santibernaldo


1 Answers

Cocoa error 516 means that a file already exists. In your case, it seems that the image file already exists in the local cache.

You can try to check with isDataAvailable() first before you call getDataInBackgroundWithBlock.

Also, I believe this is warning should be a bug in parse. Be sure you are using the latest version of the parse framework.

like image 54
Marius Waldal Avatar answered Jan 29 '26 05:01

Marius Waldal