X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/2a913bfbeb13fc93ad0ec942d359dbcaa3ad3c1e..4476c047364e6697372b9d6e9da6371cece2d62f:/src/com/owncloud/android/operations/SynchronizeFolderOperation.java diff --git a/src/com/owncloud/android/operations/SynchronizeFolderOperation.java b/src/com/owncloud/android/operations/SynchronizeFolderOperation.java index 36c3f3f0..eaf3c3eb 100644 --- a/src/com/owncloud/android/operations/SynchronizeFolderOperation.java +++ b/src/com/owncloud/android/operations/SynchronizeFolderOperation.java @@ -21,6 +21,7 @@ package com.owncloud.android.operations; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; +import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.HashMap; @@ -296,14 +297,10 @@ public class SynchronizeFolderOperation extends RemoteOperation { private void checkAndFixForeignStoragePath(OCFile file) { String storagePath = file.getStoragePath(); String expectedPath = FileStorageUtils.getDefaultSavePathFor(mAccount.name, file); - File ocLocalFolder = new File(FileStorageUtils.getSavePath(mAccount.name)); if (storagePath != null && !storagePath.equals(expectedPath)) { /// fix storagePaths out of the local ownCloud folder File originalFile = new File(storagePath); - mForgottenLocalFiles.put(file.getRemotePath(), storagePath); // TODO REMOVE - - /* TO TEST NOTIFICATION!!! - TODO UNCOMMENT - if (ocLocalFolder.getUsableSpace() < originalFile.length()) { + if (FileStorageUtils.getUsableSpace(mAccount.name) < originalFile.length()) { mForgottenLocalFiles.put(file.getRemotePath(), storagePath); file.setStoragePath(null); @@ -312,6 +309,15 @@ public class SynchronizeFolderOperation extends RemoteOperation { OutputStream out = null; try { File expectedFile = new File(expectedPath); + File expectedParent = expectedFile.getParentFile(); + expectedParent.mkdirs(); + if (!expectedParent.isDirectory()) { + throw new IOException("Unexpected error: parent directory could not be created"); + } + expectedFile.createNewFile(); + if (!expectedFile.isFile()) { + throw new IOException("Unexpected error: target file could not be created"); + } in = new FileInputStream(originalFile); out = new FileOutputStream(expectedFile); byte[] buf = new byte[1024]; @@ -322,6 +328,7 @@ public class SynchronizeFolderOperation extends RemoteOperation { file.setStoragePath(expectedPath); } catch (Exception e) { + Log.e(TAG, "Exception while copying foreign file " + expectedPath, e); mForgottenLocalFiles.put(file.getRemotePath(), storagePath); file.setStoragePath(null); @@ -338,7 +345,6 @@ public class SynchronizeFolderOperation extends RemoteOperation { } } } - */ } }