- for (int i=0; i < localPaths.length; i++) {
- OwnCloudVersion ocv = new OwnCloudVersion(AccountManager.get(this).getUserData(account, AccountAuthenticator.KEY_OC_VERSION));
- if (FileUploader.chunkedUploadIsSupported(ocv)) {
- mUploads.add(new ChunkedUploadFileOperation(localPaths[i], remotePaths[i], ((mimeTypes!=null)?mimeTypes[i]:""), isInstant, forceOverwrite, this));
- } else {
- mUploads.add(new UploadFileOperation(localPaths[i], remotePaths[i], (mimeTypes!=null?mimeTypes[i]:""), isInstant, forceOverwrite, this));
+ OwnCloudVersion ocv = new OwnCloudVersion(AccountManager.get(this).getUserData(account, AccountAuthenticator.KEY_OC_VERSION));
+ boolean chunked = FileUploader.chunkedUploadIsSupported(ocv);
+ AbstractList<String> requestedUploads = new Vector<String>();
+ String uploadKey = null;
+ UploadFileOperation newUpload = null;
+ OCFile file = null;
+ FileDataStorageManager storageManager = new FileDataStorageManager(account, getContentResolver());
+ boolean fixed = false;
+ if (isInstant) {
+ fixed = checkAndFixInstantUploadDirectory(storageManager);
+ }
+ try {
+ for (int i=0; i < localPaths.length; i++) {
+ uploadKey = buildRemoteName(account, remotePaths[i]);
+ file = obtainNewOCFileToUpload(remotePaths[i], localPaths[i], ((mimeTypes!=null)?mimeTypes[i]:(String)null), isInstant, forceOverwrite, storageManager);
+ if (chunked) {
+ newUpload = new ChunkedUploadFileOperation(account, file, isInstant, forceOverwrite);
+ } else {
+ newUpload = new UploadFileOperation(account, file, isInstant, forceOverwrite);
+ }
+ if (fixed && i==0) {
+ newUpload.setRemoteFolderToBeCreated();
+ }
+ mPendingUploads.putIfAbsent(uploadKey, newUpload);
+ newUpload.addDatatransferProgressListener(this);
+ requestedUploads.add(uploadKey);