Changes
This commit is contained in:
parent
5c58cecb61
commit
bcb9956c6e
@ -185,7 +185,7 @@ public class CheckCommand implements Command {
|
||||
LOG.error("Part {}: KO. Failed.", CheckCommandPart.MIGRATE_DB_SCHEMA_IF_NEEDED.number);
|
||||
throw new RuntimeException("Part " + CheckCommandPart.MIGRATE_DB_SCHEMA_IF_NEEDED.number + ": KO. Failed.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (RuntimeException e) {
|
||||
LOG.error("Part {}: KO. {}", CheckCommandPart.MIGRATE_DB_SCHEMA_IF_NEEDED.number, e.getMessage());
|
||||
return false;
|
||||
}
|
||||
@ -212,7 +212,7 @@ public class CheckCommand implements Command {
|
||||
List<File> filesAlreadyFound = new ArrayList<>();
|
||||
List<File> filesInDirList = foundFilesInCurrentDir(bitBackupFiles.getWorkingDir(), filesAlreadyFound, bitBackupFiles);
|
||||
|
||||
Utils.writeTextToFile(bitbackupindex.toString(), new File("bitbackupindex"));
|
||||
Utils.writeTextToFile(bitbackupindexSB.toString(), bitBackupFiles.getBitbackupindex());
|
||||
ListSet<File> listSet = new ListSet<>(filesInDirList, f -> loadPathButOnlyTheNeededPart(bitBackupFiles.getWorkingDir(), f));
|
||||
|
||||
LOG.info("Part {}: Found {} files.", CheckCommandPart.FOUND_FILES_IN_FILESYSTEM.number, listSet.size());
|
||||
@ -225,7 +225,7 @@ public class CheckCommand implements Command {
|
||||
private String loadPathButOnlyTheNeededPart(File currentDir, File file) {
|
||||
return file.getAbsolutePath().substring(currentDir.getAbsolutePath().length() + 1);
|
||||
}
|
||||
private StringBuilder bitbackupindex = new StringBuilder();
|
||||
private final StringBuilder bitbackupindexSB = new StringBuilder();
|
||||
static int iii = 0;
|
||||
|
||||
private int foundFiles;
|
||||
@ -238,13 +238,13 @@ public class CheckCommand implements Command {
|
||||
|
||||
boolean isBitBackupIgnore = f.getName().equals(bitBackupFiles.getBitBackupIgnore().getName());
|
||||
|
||||
if (isBitBackupIgnore && !f.getAbsolutePath().equals(bitBackupFiles.getBitBackupIgnore().getAbsoluteFile())) {
|
||||
if (isBitBackupIgnore && !f.getAbsolutePath().equals(bitBackupFiles.getBitBackupIgnore().getAbsolutePath())) {
|
||||
bitBackupFiles.getBitBackupIgnoreRegex().addBitBackupIgnoreFile(f, bitBackupFiles.getWorkingDir());
|
||||
}
|
||||
if (f.isDirectory()) {
|
||||
++foundDirs;
|
||||
try {
|
||||
bitbackupindex.append(new FileEntry(f).toCsvLine()).append("\n");
|
||||
bitbackupindexSB.append(new FileEntry(f).toCsvLine()).append("\n");
|
||||
} catch (IOException ex) {
|
||||
java.util.logging.Logger.getLogger(CheckCommand.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
@ -264,7 +264,7 @@ public class CheckCommand implements Command {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
bitbackupindex.append(new FileEntry(f).toCsvLine()).append("\n");
|
||||
bitbackupindexSB.append(new FileEntry(f).toCsvLine()).append("\n");
|
||||
} catch (IOException ex) {
|
||||
java.util.logging.Logger.getLogger(CheckCommand.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class HelpCommand implements Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String run(BitBackupArgs bitInspectorArgs) {
|
||||
public String run(BitBackupArgs bitBackupArgs) {
|
||||
String str = """
|
||||
NAME
|
||||
bitbackup - " Bit Backup"
|
||||
|
@ -42,7 +42,7 @@ private static final Logger LOG = LogManager.getLogger(VersionCommand.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String run(BitBackupArgs bitInspectorArgs) {
|
||||
public String run(BitBackupArgs bitBackupArgs) {
|
||||
String result = "Bit Backup 0.0.0-SNAPSHOT";
|
||||
LOG.info(result);
|
||||
return result;
|
||||
|
@ -32,12 +32,12 @@ import com.robertvokac.bitbackup.commands.VersionCommand;
|
||||
*
|
||||
* @author <a href="mailto:mail@robertvokac.com">Robert Vokac</a>
|
||||
*/
|
||||
public class BitInspector {
|
||||
public class BitBackup {
|
||||
|
||||
private static final Logger LOG = LogManager.getLogger(BitInspector.class);
|
||||
private static final Logger LOG = LogManager.getLogger(BitBackup.class);
|
||||
|
||||
private final Set<Command> commandImplementations;
|
||||
public BitInspector() {
|
||||
public BitBackup() {
|
||||
commandImplementations = new HashSet<>();
|
||||
commandImplementations.add(new CheckCommand());
|
||||
commandImplementations.add(new HelpCommand());
|
@ -43,7 +43,7 @@ public class BitBackupArgs {
|
||||
return array;
|
||||
}
|
||||
|
||||
public BitBackupArgs(BitInspectorCommand command, Map<String, String> map) {
|
||||
public BitBackupArgs(BitBackupCommand command, Map<String, String> map) {
|
||||
this(convertToStringArray(command.name().toLowerCase(), map));
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,6 @@ package com.robertvokac.bitbackup.core;
|
||||
*
|
||||
* @author <a href="mailto:mail@robertvokac.com">Robert Vokac</a>
|
||||
*/
|
||||
public enum BitInspectorCommand {
|
||||
public enum BitBackupCommand {
|
||||
CHECK, HELP, VERSION;
|
||||
}
|
@ -36,9 +36,9 @@ public class BitBackupContext {
|
||||
private final String directoryWhereSqliteFileIs;
|
||||
private ConnectionFactory connectionFactory;
|
||||
@Getter
|
||||
private SystemItemRepository systemItemRepository;
|
||||
private final SystemItemRepository systemItemRepository;
|
||||
@Getter
|
||||
private FileRepository fileRepository;
|
||||
private final FileRepository fileRepository;
|
||||
|
||||
public BitBackupContext(String directoryWhereSqliteFileIs) {
|
||||
this.directoryWhereSqliteFileIs = directoryWhereSqliteFileIs;
|
||||
|
@ -39,10 +39,8 @@ public class BitBackupFiles {
|
||||
private final File bitBackupIgnore;
|
||||
private final BitBackupIgnoreRegex bitBackupIgnoreRegex;
|
||||
private final File bitBackupReportCsv;
|
||||
private final File bitbackupindex;
|
||||
|
||||
|
||||
|
||||
|
||||
public BitBackupFiles(BitBackupArgs bitInspectorArgs) {
|
||||
workingDir = new File(bitInspectorArgs.hasArgument("dir") ? bitInspectorArgs.getArgument("dir") : ".");
|
||||
workingDirAbsolutePath = workingDir.getAbsolutePath();
|
||||
@ -51,5 +49,6 @@ public class BitBackupFiles {
|
||||
bitBackupIgnore = new File(workingDirAbsolutePath + "/.bitbackupignore");
|
||||
bitBackupIgnoreRegex = new BitBackupIgnoreRegex(bitBackupIgnore);
|
||||
bitBackupReportCsv = new File(workingDirAbsolutePath + "/.bitbackupreport.csv");
|
||||
bitbackupindex = new File(workingDirAbsolutePath + "/.bitbackupindex.csv");
|
||||
}
|
||||
}
|
||||
|
@ -28,8 +28,8 @@ public class Main {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Bir - Detects bit rotten files in the given directory to keep your files forever.\n");
|
||||
|
||||
BitInspector bitInspector = new BitInspector();
|
||||
bitInspector.run(args);
|
||||
BitBackup bitBackup = new BitBackup();
|
||||
bitBackup.run(args);
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,12 +19,6 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.robertvokac.bitbackup.persistence.impl.sqlite;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import com.robertvokac.bitbackup.core.Constants;
|
||||
import com.robertvokac.bitbackup.core.Utils;
|
||||
import com.robertvokac.dbmigration.core.main.DBMigration;
|
||||
import com.robertvokac.dbmigration.core.main.MigrationResult;
|
||||
|
Loading…
x
Reference in New Issue
Block a user