We've been successfully utilizing the dropbox-sdk-obj-c client library in our iOS/macOS app for years now, so thank you for providing this. We're using the latest tagged release version (7.4.1).
Over the last year or so we've had intermittent reports from a few users running into an issue with one of our upload requests and wanted to ask here for guidance on further troubleshooting steps or possible causes.
Overview of usage
Our application allows users to upload pieces of data from our application to their personal Dropbox as a means of backing up their data. To do this we:
- Check if the expected folder structure exists in Dropbox and create it if it doesn't (
/<company name>/<sub-folder>)
- Check for the existence of a text file named
sync.lock (indicating that another client is in the process of uploading) and bail out with an error if one exists.
- Upload a simple text file named
sync.lock to indicate that one of the clients is in the process of uploading data and to block all other clients from uploading at the same time.
- Perform the actual upload of data.
- Delete the
sync.lock file to indicate that this client has completed.
Where the issue occurs
The issue occurs at step 3 of above, within the uploadUrl completion block we're getting back nil for the DBFILESFileMetadata and a DBRequestError as follows:
DropboxClientError[{
NSError = "Error Domain=NSPOSIXErrorDomain Code=2 \"No such file or directory\" UserInfo={NSErrorFailingURLStringKey=https://api-content.dropbox.com/2/files/upload, NSErrorFailingURLKey=https://api-content.dropbox.com/2/files/upload, _NSURLErrorRelatedURLSessionTaskErrorKey=(\n \"BackgroundUploadTask <GUID>.<5>\",\n \"LocalDownloadTask <GUID>.<5>\"\n), _NSURLErrorFailingURLSessionTaskErrorKey=BackgroundUploadTask <GUID>.<5>}";
}
The users report that when they view the /<company name>/<sub-folder> location within the Dropbox webapp it appears that the sync.lock file was successfully created there.
Relevant Code
...
// create our sync lock file
SLog(@"Attempting to create sync.lock file locally");
NSError *writeError = nil;
NSString *randomStringToWrite = @"Blarg123";
NSString *localPath = <local file path in container accessible to application>/sync.lock;
BOOL success = [randomStringToWrite writeToFile:localPath atomically:YES encoding:NSUTF8StringEncoding error:&writeError];
SLog(@"Result of attempting to write to file = %d", success);
// as long as there was no write error for the sync file, let's send it out to Dropbox
if (!writeError) {
SLog(@"No write error, attempting to upload sync lock file");
// self.rootPath is established as /<company name>/<sub-folder>
NSString *destinationPath = [NSString stringWithFormat:@"%@/%@", self.rootPath, self.syncLockFileName];
SLog(@"Does sync lock exist at path %d", [[NSFileManager defaultManager] fileExistsAtPath:localPath]);
SLog(@"Uploading sync lock to %@ from local file %@", destinationPath, localPath);
DBFILESWriteMode *addMode = [[DBFILESWriteMode alloc] initWithAdd];
self.currentTask = [[client.filesRoutes uploadUrl:destinationPath
mode:addMode
autorename:@(NO)
clientModified:nil
mute:@(YES)
propertyGroups:nil
strictConflict:nil
contentHash:nil
inputUrl:localPath]
setResponseBlock:^(DBFILESFileMetadata * _Nullable result, DBFILESUploadError * _Nullable routeError, DBRequestError * _Nullable error) {
SLog(@"Response from upload, result != nil = %d, routeError = %@, requestError = %@", result != nil, routeError, error);
if (result != nil) {
// Success!
// continue on with the rest of the process
} else {
// Report error to the user
...
Log output
Attempting to create sync.lock file locally
Result of attempting to write to file = 1
No write error, attempting to upload sync lock file
Does sync lock exist at path 1
Uploading sync lock to /<company name>/<sub-folder>/sync.lock from local file <absolute path to container>/sync.lock
Response from upload, result != nil = 0, routeError = (null), requestError = DropboxClientError[{
NSError = "Error Domain=NSPOSIXErrorDomain Code=2 \"No such file or directory\" UserInfo={NSErrorFailingURLStringKey=https://api-content.dropbox.com/2/files/upload, NSErrorFailingURLKey=https://api-content.dropbox.com/2/files/upload, _NSURLErrorRelatedURLSessionTaskErrorKey=(\n \"BackgroundUploadTask <GUID>.<5>\",\n \"LocalDownloadTask <GUID>.<5>\"\n), _NSURLErrorFailingURLSessionTaskErrorKey=BackgroundUploadTask <GUID>.<5>}";
Additional Comments/Questions
- This issue has only been reported in our macOS app. Our iOS app which uses the same shared code-path for uploading the
sync.lock file hasn't had any reports of a similar issue. And some of the users who report this issue are using both our iOS and macOS with the same Dropbox account.
- We haven't been able to reproduce this issue ourselves on any of our machines
- Are there any known causes of this issue (or how to avoid it)?
- We've asked reporting users to confirm that their Dropbox account has sufficient space, Is there anything related to the user's Dropbox account which could be causing it?
- Is there any additional logging we can add to try to get additional information as to the root cause?
- I've tried experimenting some with trying to reproduce the issue by programmatically using flock and chmod, with chmod I was able to create a separate error when completing removing read/write permissions which is expected (DBFILESWriteError)
We've been successfully utilizing the
dropbox-sdk-obj-cclient library in our iOS/macOS app for years now, so thank you for providing this. We're using the latest tagged release version (7.4.1).Over the last year or so we've had intermittent reports from a few users running into an issue with one of our upload requests and wanted to ask here for guidance on further troubleshooting steps or possible causes.
Overview of usage
Our application allows users to upload pieces of data from our application to their personal Dropbox as a means of backing up their data. To do this we:
/<company name>/<sub-folder>)sync.lock(indicating that another client is in the process of uploading) and bail out with an error if one exists.sync.lockto indicate that one of the clients is in the process of uploading data and to block all other clients from uploading at the same time.sync.lockfile to indicate that this client has completed.Where the issue occurs
The issue occurs at step 3 of above, within the uploadUrl completion block we're getting back nil for the
DBFILESFileMetadataand aDBRequestErroras follows:The users report that when they view the
/<company name>/<sub-folder>location within the Dropbox webapp it appears that thesync.lockfile was successfully created there.Relevant Code
Log output
Additional Comments/Questions
sync.lockfile hasn't had any reports of a similar issue. And some of the users who report this issue are using both our iOS and macOS with the same Dropbox account.