Package org.syncany.operations.ls

Examples of org.syncany.operations.ls.LsOperationOptions


    // Repeat request until 3 files are found.
    FileVersion[] files = null;
   
    for (int i = 0; i < 20; i++) {
      LsFolderRequest request = new LsFolderRequest();
      LsOperationOptions lsOperationOption = new LsOperationOptions();
     
      request.setId(i);
      request.setRoot(clientA.getConfig().getLocalDir().getAbsolutePath());
      request.setOptions(lsOperationOption);
      eventBus.post(request);
View Full Code Here


    return true;
  }

  @Override
  public int execute(String[] operationArgs) throws Exception {
    LsOperationOptions operationOptions = parseOptions(operationArgs);
    LsOperationResult operationResult = client.ls(operationOptions);

    printResults(operationResult);

    return 0;
View Full Code Here

    return 0;
 

  @Override
  public LsOperationOptions parseOptions(String[] operationArgs) throws Exception {
    LsOperationOptions operationOptions = new LsOperationOptions();

    OptionParser parser = new OptionParser();
    parser.allowsUnrecognizedOptions();
   
    OptionSpec<String> optionDateStr = parser.acceptsAll(asList("D", "date")).withRequiredArg();
    OptionSpec<Void> optionRecursive = parser.acceptsAll(asList("r", "recursive"));
    OptionSpec<String> optionFileTypes = parser.acceptsAll(asList("t", "types")).withRequiredArg();
    OptionSpec<Void> optionLongChecksums = parser.acceptsAll(asList("f", "full-checksums"));
    OptionSpec<Void> optionWithVersions = parser.acceptsAll(asList("V", "versions"));
    OptionSpec<Void> optionGroupedVersions = parser.acceptsAll(asList("g", "group"));

    OptionSet options = parser.parse(operationArgs);

    // --date=..
    if (options.has(optionDateStr)) {     
      Date logViewDate = parseDateOption(options.valueOf(optionDateStr));
      operationOptions.setDate(logViewDate);
    }
   
    // --recursive
    operationOptions.setRecursive(options.has(optionRecursive));
   
    // --types=[tds]
    if (options.has(optionFileTypes)) {
      String fileTypesStr = options.valueOf(optionFileTypes).toLowerCase();
      HashSet<FileType> fileTypes = new HashSet<>();
     
      if (fileTypesStr.contains("f")) {
        fileTypes.add(FileType.FILE);
      }
     
      if (fileTypesStr.contains("d")) {
        fileTypes.add(FileType.FOLDER);
      }
     
      if (fileTypesStr.contains("s")) {
        fileTypes.add(FileType.SYMLINK);
      }
     
      operationOptions.setFileTypes(fileTypes);
    }
       
    // --versions
    fetchHistories = options.has(optionWithVersions);
    operationOptions.setFetchHistories(fetchHistories);
   
    // --long-checksums (display option)
    checksumLength = (options.has(optionLongChecksums)) ? CHECKSUM_LENGTH_LONG : CHECKSUM_LENGTH_SHORT;

    // --group (display option)
    groupedVersions = options.has(optionGroupedVersions);
   
    // <path-expr>
    List<?> nonOptionArgs = options.nonOptionArguments();
   
    if (nonOptionArgs.size() > 0) {
      operationOptions.setPathExpression(nonOptionArgs.get(0).toString());
    }

    return operationOptions;
  }
View Full Code Here

   
    // A just upped, so there should not be changes.
    assertFalse(clientA.status().getChangeSet().hasChanges());
   
    // Check if the file histories were based on the correct originals
    LsOperationOptions options = new LsOperationOptions();
    options.setFetchHistories(true);
    options.setPathExpression("moved_folder/subfolder1/");
   
    LsOperationResult lsOperationResult = clientA.ls(options);
   
    for (PartialFileHistory fileHistory : lsOperationResult.getFileVersions().values()) {
      assertTrue(fileHistory.getFileVersion(2).getPath().endsWith(fileHistory.getFileVersion(1).getPath()));
    }
   
    options.setPathExpression("moved_folder/subfolder2/");
   
    lsOperationResult = clientA.ls(options);
   
    for (PartialFileHistory fileHistory : lsOperationResult.getFileVersions().values()) {
      assertTrue(fileHistory.getFileVersion(2).getPath().endsWith(fileHistory.getFileVersion(1).getPath()));
View Full Code Here

TOP

Related Classes of org.syncany.operations.ls.LsOperationOptions

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.