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

Commit

Permalink
Re-adding move methods to TM's
Browse files Browse the repository at this point in the history
  • Loading branch information
pimotte committed Aug 12, 2014
1 parent 3f52e32 commit 1de7d10
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ build
gradle/arch/syncany/pkg
gradle/arch/syncany/src
gradle/arch/syncany/syncany*.tar*
*.orig
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;
import org.syncany.config.Config;
import org.syncany.plugins.StorageException;
import org.syncany.plugins.transfer.TransferManager;
import org.syncany.plugins.transfer.files.RemoteFile;

/**
* This class represents a transaction in a remote system. It will keep track of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.syncany.plugins.StorageException;
import org.syncany.plugins.transfer.files.RemoteFile;

/**
* The temp file represents a temporary file on the remote storage.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.syncany.plugins.StorageException;
import org.syncany.plugins.transfer.files.RemoteFile;

/**
* The transaction file represents a manifest of a transaction on the remote storage.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import org.simpleframework.xml.Root;
import org.simpleframework.xml.core.Commit;
import org.simpleframework.xml.core.Persist;
import org.syncany.plugins.StorageException;
import org.syncany.plugins.transfer.files.RemoteFile;

/**
* The Transaction transfer object exists to serialize a transaction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,22 @@ public void download(RemoteFile remoteFile, File localFile) throws StorageExcept
throw new StorageException("Unable to copy file " + repoFile + " from local repository to " + localFile, ex);
}
}

@Override
public void move(RemoteFile sourceFile, RemoteFile targetFile) throws StorageException {
connect();

File sourceRemoteFile = getRemoteFile(sourceFile);
File targetRemoteFile = getRemoteFile(targetFile);

try {
FileUtils.moveFile(sourceRemoteFile, targetRemoteFile);
}
catch (IOException ex) {
throw new StorageException("Unable to move file " + sourceRemoteFile + " to destination " + targetRemoteFile, ex);
}
}

@Override
public void upload(File localFile, RemoteFile remoteFile) throws StorageException {
connect();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@ public Object execute() throws StorageException {
}
});
}

@Override
public void move(final RemoteFile sourceFile, final RemoteFile targetFile) throws StorageException {
retryMethod(new RetriableMethod() {
@Override
public Object execute() throws StorageException {
underlyingTransferManager.move(sourceFile, targetFile);
return null;
}
});
}

@Override
public void upload(final File localFile, final RemoteFile remoteFile) throws StorageException {
Expand Down

0 comments on commit 1de7d10

Please sign in to comment.