mirror of
https://github.com/openeggbert/bit-backup.git
synced 2025-03-25 15:37:53 +01:00
Improvements
This commit is contained in:
parent
bcb9956c6e
commit
3ef40e52af
@ -25,7 +25,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
@ -105,7 +104,12 @@ public class CheckCommand implements Command {
|
|||||||
//part 3:
|
//part 3:
|
||||||
part3UpdateVersionInDbIfNeeded(bitBackupContext, bitBackupFiles);
|
part3UpdateVersionInDbIfNeeded(bitBackupContext, bitBackupFiles);
|
||||||
|
|
||||||
ListSet<File> filesInFileSystem = part4FoundFilesInFileSystem(bitBackupFiles, bitBackupArgs);
|
ListSet<File> filesInFileSystem;
|
||||||
|
try {
|
||||||
|
filesInFileSystem = part4FoundFilesInFileSystem(bitBackupFiles, bitBackupArgs);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
return "Part 4 failed: " + ex.getMessage();
|
||||||
|
}
|
||||||
ListSet<FsFile> filesInDb = part5FoundFilesInDb(bitBackupContext.getFileRepository(), bitBackupArgs);
|
ListSet<FsFile> filesInDb = part5FoundFilesInDb(bitBackupContext.getFileRepository(), bitBackupArgs);
|
||||||
|
|
||||||
LocalDateTime now = part6AddNewFilesToDb(filesInFileSystem, bitBackupFiles, filesInDb, bitBackupContext);
|
LocalDateTime now = part6AddNewFilesToDb(filesInFileSystem, bitBackupFiles, filesInDb, bitBackupContext);
|
||||||
@ -206,19 +210,18 @@ public class CheckCommand implements Command {
|
|||||||
}
|
}
|
||||||
public static final String BIBVERSION = "bib.version";
|
public static final String BIBVERSION = "bib.version";
|
||||||
|
|
||||||
private ListSet<File> part4FoundFilesInFileSystem(BitBackupFiles bitBackupFiles, BitBackupArgs bitBackupArgs) {
|
private ListSet<File> part4FoundFilesInFileSystem(BitBackupFiles bitBackupFiles, BitBackupArgs bitBackupArgs) throws IOException {
|
||||||
LOG.info("** Part {}: Loading files in filesystem", CheckCommandPart.FOUND_FILES_IN_FILESYSTEM.number);
|
LOG.info("** Part {}: Loading files in filesystem", CheckCommandPart.FOUND_FILES_IN_FILESYSTEM.number);
|
||||||
String workingDir = bitBackupFiles.getWorkingDirAbsolutePath();
|
String workingDir = bitBackupFiles.getWorkingDirAbsolutePath();
|
||||||
List<File> filesAlreadyFound = new ArrayList<>();
|
List<File> filesAlreadyFound = new ArrayList<>();
|
||||||
List<File> filesInDirList = foundFilesInCurrentDir(bitBackupFiles.getWorkingDir(), filesAlreadyFound, bitBackupFiles);
|
List<File> filesInDirList = foundFilesInCurrentDir(bitBackupFiles.getWorkingDir(), filesAlreadyFound, bitBackupFiles, bitBackupArgs, workingDir);
|
||||||
|
|
||||||
|
if(bitBackupArgs.isBitBackupIndexEnabled()) {
|
||||||
Utils.writeTextToFile(bitbackupindexSB.toString(), bitBackupFiles.getBitbackupindex());
|
Utils.writeTextToFile(bitbackupindexSB.toString(), bitBackupFiles.getBitbackupindex());
|
||||||
|
}
|
||||||
ListSet<File> listSet = new ListSet<>(filesInDirList, f -> loadPathButOnlyTheNeededPart(bitBackupFiles.getWorkingDir(), f));
|
ListSet<File> listSet = new ListSet<>(filesInDirList, f -> loadPathButOnlyTheNeededPart(bitBackupFiles.getWorkingDir(), f));
|
||||||
|
|
||||||
LOG.info("Part {}: Found {} files.", CheckCommandPart.FOUND_FILES_IN_FILESYSTEM.number, listSet.size());
|
LOG.info("Part {}: Found {} files.", CheckCommandPart.FOUND_FILES_IN_FILESYSTEM.number, listSet.size());
|
||||||
if (bitBackupArgs.isVerboseLoggingEnabled()) {
|
|
||||||
filesInDirList.stream().forEach((f -> LOG.info("#" + (++iStatic) + " " + f.getAbsolutePath().substring(workingDir.length() + 1))));
|
|
||||||
}
|
|
||||||
return listSet;
|
return listSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,7 +234,7 @@ public class CheckCommand implements Command {
|
|||||||
private int foundFiles;
|
private int foundFiles;
|
||||||
private int foundDirs;
|
private int foundDirs;
|
||||||
|
|
||||||
private List<File> foundFilesInCurrentDir(File currentDir, List<File> filesAlreadyFound, BitBackupFiles bitBackupFiles) {
|
private List<File> foundFilesInCurrentDir(File currentDir, List<File> filesAlreadyFound, BitBackupFiles bitBackupFiles, BitBackupArgs bitBackupArgs, String workingDir) throws IOException {
|
||||||
|
|
||||||
for (File f : currentDir.listFiles()) {
|
for (File f : currentDir.listFiles()) {
|
||||||
|
|
||||||
@ -243,12 +246,10 @@ public class CheckCommand implements Command {
|
|||||||
}
|
}
|
||||||
if (f.isDirectory()) {
|
if (f.isDirectory()) {
|
||||||
++foundDirs;
|
++foundDirs;
|
||||||
try {
|
if (bitBackupArgs.isBitBackupIndexEnabled()) {
|
||||||
bitbackupindexSB.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);
|
|
||||||
}
|
}
|
||||||
foundFilesInCurrentDir(f, filesAlreadyFound, bitBackupFiles);
|
foundFilesInCurrentDir(f, filesAlreadyFound, bitBackupFiles, bitBackupArgs, workingDir);
|
||||||
} else {
|
} else {
|
||||||
++foundFiles;
|
++foundFiles;
|
||||||
if (f.getAbsolutePath().equals(bitBackupFiles.getBitBackupSQLite3File().getAbsolutePath())) {
|
if (f.getAbsolutePath().equals(bitBackupFiles.getBitBackupSQLite3File().getAbsolutePath())) {
|
||||||
@ -263,12 +264,14 @@ public class CheckCommand implements Command {
|
|||||||
if (bitBackupFiles.getBitBackupIgnoreRegex().test(loadPathButOnlyTheNeededPart(bitBackupFiles.getWorkingDir(), f))) {
|
if (bitBackupFiles.getBitBackupIgnoreRegex().test(loadPathButOnlyTheNeededPart(bitBackupFiles.getWorkingDir(), f))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
if (bitBackupArgs.isBitBackupIndexEnabled()) {
|
||||||
bitbackupindexSB.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);
|
|
||||||
}
|
}
|
||||||
filesAlreadyFound.add(f);
|
filesAlreadyFound.add(f);
|
||||||
|
|
||||||
|
if (bitBackupArgs.isVerboseLoggingEnabled() || iStatic % 100 == 0) {
|
||||||
|
LOG.info("Found file in file system: #" + (++iStatic) + " " + f.getAbsolutePath().substring(workingDir.length() + 1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return filesAlreadyFound;
|
return filesAlreadyFound;
|
||||||
|
@ -87,5 +87,9 @@ public class BitBackupArgs {
|
|||||||
public boolean isVerboseLoggingEnabled() {
|
public boolean isVerboseLoggingEnabled() {
|
||||||
return hasArgument("verbose")&&getArgument("verbose").equals("true");
|
return hasArgument("verbose")&&getArgument("verbose").equals("true");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isBitBackupIndexEnabled() {
|
||||||
|
return hasArgument("bitbackupindex")&&getArgument("bitbackupindex").equals("true");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user