Skip to content
This repository has been archived by the owner on Jul 26, 2022. It is now read-only.

Commit

Permalink
Commenting and removing legacy code
Browse files Browse the repository at this point in the history
  • Loading branch information
binwiederhier committed Aug 17, 2014
1 parent a68b4e6 commit 30a9d48
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@
package org.syncany.plugins;

/**
* @author pim-arch
*
* The storage move exception is thrown if moving a file on
* the remote storage fails. This usually happens if the original file
* does not exist.
*
* @author Pim Otte
*/
public class StorageMoveException extends StorageException {
private static final long serialVersionUID = 8929643336708862710L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@
package org.syncany.plugins.local;

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;
import java.util.HashSet;
import java.util.Map;
Expand Down Expand Up @@ -134,7 +130,7 @@ public void download(RemoteFile remoteFile, File localFile) throws StorageExcept
File tempLocalFile = createTempFile("local-tm-download");
tempLocalFile.deleteOnExit();

copyLocalFile(repoFile, tempLocalFile);
FileUtils.copyFile(repoFile, tempLocalFile);

localFile.delete();
FileUtils.moveFile(tempLocalFile, localFile);
Expand Down Expand Up @@ -182,7 +178,7 @@ public void upload(File localFile, RemoteFile remoteFile) throws StorageExceptio
}

try {
copyLocalFile(localFile, tempRepoFile);
FileUtils.copyFile(localFile, tempRepoFile);
FileUtils.moveFile(tempRepoFile, repoFile);
}
catch (IOException ex) {
Expand Down Expand Up @@ -231,8 +227,8 @@ public <T extends RemoteFile> Map<String, T> list(Class<T> remoteFileClass) thro
Map<String, T> remoteFiles = new HashMap<String, T>();

for (RemoteFile deletedFile : dummyDeletedFiles) {
if (deletedFile.getClass().equals(remoteFileClass)) {
T deletedTFile = (T) deletedFile;
if (deletedFile.getClass().equals(remoteFileClass)) {
T deletedTFile = remoteFileClass.cast(deletedFile);
remoteFiles.put(deletedTFile.getName(), deletedTFile);
}
}
Expand All @@ -254,7 +250,7 @@ public <T extends RemoteFile> Map<String, T> list(Class<T> remoteFileClass) thro
}

private File getRemoteFile(RemoteFile remoteFile) {
return new File(getRemoteFilePath(remoteFile.getClass()) + File.separator + remoteFile.getName());
return new File(getRemoteFilePath(remoteFile.getClass()), remoteFile.getName());
}

private File getRemoteFilePath(Class<? extends RemoteFile> remoteFile) {
Expand All @@ -272,21 +268,6 @@ else if (remoteFile.equals(ActionRemoteFile.class)) {
}
}

public void copyLocalFile(File src, File dst) throws IOException {
InputStream in = new FileInputStream(src);
OutputStream out = new FileOutputStream(dst);

byte[] buf = new byte[4096];

int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}

in.close();
out.close();
}

public String getAbsoluteParentDirectory(File file) {
return file.getAbsolutePath().substring(0, file.getAbsolutePath().lastIndexOf(File.separator));
}
Expand Down

0 comments on commit 30a9d48

Please sign in to comment.