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

Commit

Permalink
Merged atomic operations into rest-cli branch
Browse files Browse the repository at this point in the history
  • Loading branch information
binwiederhier committed Sep 11, 2014
2 parents 0fd1035 + 8e63b54 commit 3df4585
Show file tree
Hide file tree
Showing 87 changed files with 3,722 additions and 1,833 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
3 changes: 2 additions & 1 deletion gradle/bash/syncany.bash-completion
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ _sy() {

CLEANUP_OPTIONS="\
-M --no-database-merge\
-V --no-version-remove\
-V --no-version-removal\
-T --no-temp-removal\
-k --keep-versions\
$STATUS_OPTIONS"

Expand Down
10 changes: 7 additions & 3 deletions gradle/eclipse/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,17 @@ org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
org.eclipse.jdt.core.formatter.comment.format_block_comments=true
org.eclipse.jdt.core.formatter.comment.format_block_comments=false
org.eclipse.jdt.core.formatter.comment.format_header=false
org.eclipse.jdt.core.formatter.comment.format_html=true
org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=false
org.eclipse.jdt.core.formatter.comment.format_line_comments=true
org.eclipse.jdt.core.formatter.comment.format_line_comments=false
org.eclipse.jdt.core.formatter.comment.format_source_code=true
org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
Expand Down Expand Up @@ -98,6 +99,7 @@ org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert
org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
Expand Down Expand Up @@ -145,6 +147,7 @@ org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=inser
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
Expand Down Expand Up @@ -222,6 +225,7 @@ org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do n
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
Expand Down Expand Up @@ -271,7 +275,7 @@ org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constan
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.join_lines_in_comments=true
org.eclipse.jdt.core.formatter.join_wrapped_lines=true
org.eclipse.jdt.core.formatter.join_wrapped_lines=false
org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
import org.syncany.plugins.PluginOptionSpec.OptionValidationResult;
import org.syncany.plugins.PluginOptionSpecs;
import org.syncany.plugins.Plugins;
import org.syncany.plugins.StorageException;
import org.syncany.plugins.StorageTestResult;
import org.syncany.plugins.UserInteractionListener;
import org.syncany.plugins.transfer.StorageException;
import org.syncany.plugins.transfer.StorageTestResult;
import org.syncany.plugins.transfer.TransferPlugin;
import org.syncany.plugins.transfer.TransferSettings;
import org.syncany.util.StringUtil;
Expand Down
68 changes: 37 additions & 31 deletions syncany-cli/src/main/java/org/syncany/cli/CleanupCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

public class CleanupCommand extends Command {
@Override
public CommandScope getRequiredCommandScope() {
public CommandScope getRequiredCommandScope() {
return CommandScope.INITIALIZED_LOCALDIR;
}

Expand All @@ -50,68 +50,73 @@ public CleanupOperationOptions parseOptions(String[] operationArgs) throws Excep

OptionParser parser = new OptionParser();
parser.allowsUnrecognizedOptions();

OptionSpec<Void> optionForce = parser.accepts("force");
OptionSpec<Void> optionNoDatabaseMerge = parser.acceptsAll(asList("M", "no-database-merge"));
OptionSpec<Void> optionNoOldVersionRemoval = parser.acceptsAll(asList("V", "no-version-remove"));
OptionSpec<Void> optionNoOldVersionRemoval = parser.acceptsAll(asList("V", "no-version-removal"));
OptionSpec<Void> optionNoRemoveTempFiles = parser.acceptsAll(asList("T", "no-temp-removal"));
OptionSpec<Integer> optionKeepVersions = parser.acceptsAll(asList("k", "keep-versions")).withRequiredArg().ofType(Integer.class);
OptionSpec<String> optionSecondsBetweenCleanups = parser.acceptsAll(asList("t", "time-between-cleanups")).withRequiredArg().ofType(String.class);
OptionSpec<String> optionSecondsBetweenCleanups = parser.acceptsAll(asList("t", "time-between-cleanups")).withRequiredArg()
.ofType(String.class);
OptionSpec<Integer> optionMaxDatabaseFiles = parser.acceptsAll(asList("x", "max-database-files")).withRequiredArg().ofType(Integer.class);

OptionSet options = parser.parse(operationArgs);

// -F, --force
operationOptions.setForce(options.has(optionForce));

// -M, --no-database-merge
operationOptions.setMergeRemoteFiles(!options.has(optionNoDatabaseMerge));

// -V, --no-version-removal
operationOptions.setRemoveOldVersions(!options.has(optionNoOldVersionRemoval));


// -T, --no-temp-removal
operationOptions.setRemoveUnreferencedTemporaryFiles(!options.has(optionNoRemoveTempFiles));

// -k=<count>, --keep-versions=<count>
if (options.has(optionKeepVersions)) {
int keepVersionCount = options.valueOf(optionKeepVersions);

if (keepVersionCount < 1) {
throw new Exception("Invalid value for --keep-versions="+keepVersionCount+"; must be >= 1");
throw new Exception("Invalid value for --keep-versions=" + keepVersionCount + "; must be >= 1");
}
operationOptions.setKeepVersionsCount(options.valueOf(optionKeepVersions));

operationOptions.setKeepVersionsCount(options.valueOf(optionKeepVersions));
}

// -t=<count>, --time-between-cleanups=<count>
if (options.has(optionSecondsBetweenCleanups)) {
long secondsBetweenCleanups = CliUtil.parseTimePeriod(options.valueOf(optionSecondsBetweenCleanups));

if (secondsBetweenCleanups < 0) {
throw new Exception("Invalid value for --time-between-cleanups="+secondsBetweenCleanups+"; must be >= 0");
throw new Exception("Invalid value for --time-between-cleanups=" + secondsBetweenCleanups + "; must be >= 0");
}
operationOptions.setMinSecondsBetweenCleanups(secondsBetweenCleanups);

operationOptions.setMinSecondsBetweenCleanups(secondsBetweenCleanups);
}

// -d=<count>, --max-database-files=<count>
if (options.has(optionMaxDatabaseFiles)) {
int maxDatabaseFiles = options.valueOf(optionMaxDatabaseFiles);

if (maxDatabaseFiles < 1) {
throw new Exception("Invalid value for --max-database-files="+maxDatabaseFiles+"; must be >= 1");
throw new Exception("Invalid value for --max-database-files=" + maxDatabaseFiles + "; must be >= 1");
}
operationOptions.setMaxDatabaseFiles(maxDatabaseFiles);

operationOptions.setMaxDatabaseFiles(maxDatabaseFiles);
}

// Parse 'status' options
operationOptions.setStatusOptions(parseStatusOptions(operationArgs));
operationOptions.setStatusOptions(parseStatusOptions(operationArgs));

// Does this configuration make sense
boolean nothingToDo = !operationOptions.isMergeRemoteFiles() && operationOptions.isRemoveOldVersions();

if (nothingToDo) {
throw new Exception("Invalid parameter configuration: -M and -V cannot be set together. Nothing to do.");
}

return operationOptions;
}

Expand All @@ -122,23 +127,24 @@ private StatusOperationOptions parseStatusOptions(String[] operationArgs) throws

public void printResults(OperationResult operationResult) {
CleanupOperationResult concreteOperationResult = (CleanupOperationResult)operationResult;

switch (concreteOperationResult.getResultCode()) {
case NOK_DIRTY_LOCAL:
out.println("Cannot cleanup database if local repository is in a dirty state; Call 'up' first.");
break;

case NOK_RECENTLY_CLEANED:
out.println("Cleanup has been done recently, so it is not necessary. If you are sure it is necessary, override with --force.");
break;

case NOK_LOCAL_CHANGES:
out.println("Local changes detected. Please call 'up' first'.");
break;

case NOK_REMOTE_CHANGES:
out.println("Remote changes detected or repository is locked by another user. Please call 'down' first.");
break;

case NOK_OTHER_OPERATIONS_RUNNING:
out.println("Cannot run cleanup while other clients are performing up/down/cleanup. Try again later.");
break;
Expand All @@ -164,7 +170,7 @@ public void printResults(OperationResult operationResult) {
// TODO [low] This counts only the file histories, not file versions; not very helpful!
}

out.println("Cleanup successful.");
out.println("Cleanup successful.");
break;

case OK_NOTHING_DONE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import org.syncany.operations.init.ConnectOperationOptions.ConnectOptionsStrategy;
import org.syncany.operations.init.ConnectOperationResult;
import org.syncany.operations.init.ConnectOperationResult.ConnectResultCode;
import org.syncany.plugins.StorageTestResult;
import org.syncany.plugins.transfer.StorageTestResult;

public class ConnectCommand extends AbstractInitCommand {
public ConnectCommand() {
Expand Down
2 changes: 1 addition & 1 deletion syncany-cli/src/main/java/org/syncany/cli/InitCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import org.syncany.operations.init.InitOperationOptions;
import org.syncany.operations.init.InitOperationResult;
import org.syncany.operations.init.InitOperationResult.InitResultCode;
import org.syncany.plugins.StorageTestResult;
import org.syncany.plugins.transfer.StorageTestResult;
import org.syncany.util.StringUtil;
import org.syncany.util.StringUtil.StringJoinListener;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ NAME
sy-cleanup - remove old versions and free remote disk space

SYNOPSIS
sy cleanup [-M | --no-database-merge] [-V | --no-version-remove]
[-k | --keep-versions=<count>] [<status-options>]
sy cleanup [-M | --no-database-merge] [-V | --no-version-removal]
[-T | --no-temp-removal] [-k | --keep-versions=<count>]
[<status-options>]

DESCRIPTION
This command performs different operations to cleanup the local database as
Expand Down Expand Up @@ -34,10 +35,15 @@ OPTIONS
command will not merge this client's metadata files even if there are more
than 15 database files on the remote storage.

-V, --no-version-remove
-V, --no-version-removal
Turns off the removal of old versions for the command. If this is set, this
command will not shorten file histories to the <count> given by -k, and it
will not delete file versions marked as 'deleted' in the database.
will not delete file versions marked as 'deleted' in the database.

-T, --no-temp-removal
Turns off the removal of leftover temporary files for the command. If this
is set, this command will leave temporary files on the offsite storage
untouched.

-k, --keep-versions=<count>
Sets the number of file versions per file to keep in the database and the
Expand Down

0 comments on commit 3df4585

Please sign in to comment.