Renamed to Bit Backup

This commit is contained in:
Robert Vokac 2024-05-01 11:31:00 +02:00
parent ef26009a09
commit af0c107d6a
No known key found for this signature in database
GPG Key ID: C459E1E4B4A986BB
38 changed files with 389 additions and 316 deletions

View File

@ -1,5 +1,5 @@
This file partially lists people, that have contributed to
the "Bit Inspector" project. They are sorted by name.
the "Bit Backup" project. They are sorted by name.
The fields are: name (N), e-mail (E), web-address (W),
PGP key ID and fingerprint (P), description (D) and
snail-mail address (S).
@ -9,7 +9,7 @@
----------
N: Robert Vokac
E: robertvokac@nanoboot.org
E: mail@robertvokac.com
W: https://nanoboot.org
P: 4096R/E3329055 322B D109 0AA8 C324 EA9C 72F5 693D 30BE E332 9055
D: Founder

2
Jenkinsfile vendored
View File

@ -1,6 +1,6 @@
pipeline
/*
Bit Inspector
Bit Backup
Requirements:

142
README.md
View File

@ -1,27 +1,27 @@
# bit-inspector
# bit-backup
"Bit Inspector" (Bir) is a tool to manage files.
"Bit Backup" (Bib) is a tool to manage files.
## How to run
Requirements to run "Bit Inspector":
Requirements to run "Bit Backup":
* Java 21
### How to setup your environment on Linux
Add to your .bashrc:
alias bir='java -jar {path to bit-inspector jar with dependencies file}/bit-inspector-0.0.0-SNAPSHOT-jar-with-dependencies.jar'
alias bib='java -jar {path to bit-backup jar with dependencies file}/bit-backup-0.0.0-SNAPSHOT-jar-with-dependencies.jar'
## How to build
Requirements to build "Bit Inspector:
Requirements to build "Bit Backup:
* Java 21
* Maven
```
git clone https://code.nanoboot.org/nanoboot/bit-inspector
cd bit-inspector
git clone https://code.nanoboot.org/nanoboot/bit-backup
cd bit-backup
mvn clean install
```
@ -40,21 +40,21 @@ Inspired by:
* https://github.com/ambv/bitrot
* https://github.com/laktak/chkbit-py
#### File .birignore
#### File .bibignore
You can create file .birignore containing the names of the files/directories you wish to ignore
* .birignore is similar to Git file .gitignore
You can create file .bibignore containing the names of the files/directories you wish to ignore
* .bibignore is similar to Git file .gitignore
* each line should contain exactly one name
* lines starting with # are skipped
* you may use Unix shell-style wildcards
#### File .bir.sqlite3
#### File .bib.sqlite3
An SQLite database created and managed automatically by bit-inspector.
An SQLite database created and managed automatically by bit-backup.
#### File .bir.sqlite3.sha512
#### File .bib.sqlite3.sha512
Last calculated hash sum of file ".bir.sqlite3"
Last calculated hash sum of file ".bib.sqlite3"
### Feature 2 : Backup of files
@ -62,9 +62,9 @@ Inspired by Git, but goals are slightly different.
* https://github.com/joshnh/Git-Commands
* https://git-scm.com/docs
#### File .birbackup
#### File .bibbackup
File .birbackup is stored in local directory, which you are going to backup.
File .bibbackup is stored in local directory, which you are going to backup.
Content:
@ -74,45 +74,45 @@ remotes=remote1,remote2,remote3
#### Features
* Backing up directory to another location like: local, FTP(S), SFTP, HTTP(S), S3, Bir server and others
* Backing up directory to another location like: local, FTP(S), SFTP, HTTP(S), S3, Bib server and others
* Optionally you can set a password to protect your files (if a not trusted external location like FTP or S3 is used)
* Files are handled in a "Bir repository"
* Files are handled in a "Bib repository"
#### What is not supported
* Conflict resolution is not supported. (If you wish something not yet supported to be added, please, let's start a discussion here or at forum.nanoboot.org)
* "Bir" is not intended to be used by many read/write users.
* Several people changing one Bir repository must be avoided.
* "Bir" is not intended to be used by many read users and only one read/write user.
* One Bir repository can be used by more users, but only one user can change it.
* "Bib" is not intended to be used by many read/write users.
* Several people changing one Bib repository must be avoided.
* "Bib" is not intended to be used by many read users and only one read/write user.
* One Bib repository can be used by more users, but only one user can change it.
* Branches are not supported
## Bir repository
## Bib repository
* Your files are versioned. You can travel in history and return to an older version of the whole repo or only a changed/deleted directory or file.
You can:
* clone a remote Bir repository
* or use an existing local Bir repository
* or create a new empty Bir repository
* or create a new Bir repository using an existing directory
* clone a remote Bib repository
* or use an existing local Bib repository
* or create a new empty Bib repository
* or create a new Bib repository using an existing directory
* or save your local repository to a remote repository.
### Structure
#### Directory .bir/objects
#### Directory .bib/objects
.bir/objects/{??}/{?????...}
.bib/objects/{??}/{?????...}
#### Directory .bir/pack
.bir/pack/pack-{sha-512}.pack
#### Directory .bib/pack
.bib/pack/pack-{sha-512}.pack
{sha-512}::::{length in bytes}::::{sha-512}::::{length in bytes}::::{sha-512}::::{length in bytes}::::{sha-512}::::{length in bytes}::::{sha-512}::::{length in bytes}::::::::{bytes -base}{bytes-incremental}{bytes-incremental}{bytes-incremental}{bytes-incremental}{bytes-incremental}
binary diffs
#### File .bir/birindex.{number}
#### File .bib/bibindex.{number}
https://stackabuse.com/linux-display-file-properties-via-terminal/
@ -151,9 +151,9 @@ no permission - 0
```
```
Creates local .birindex
Creates local .bibindex
Downloads remote .birindex if does not exist, empty file will be returned.
Downloads remote .bibindex if does not exist, empty file will be returned.
Compares these indexes, uploads new blobs to object addressed system (SHA-512) packaged to 7z archives (compression=ultra + other settings)
@ -162,13 +162,13 @@ The most reliable way would be to make md5 hashes of all the local files you car
Using file sizes isn't reliable for the obvious reason - a file could change but have the same size. I'm not a fan of using the archive bit or modified date because either of those could be confused if you backup or restore your local directory with another backup program.
```
#### File .bir/birlog
#### File .bib/biblog
Contains index number of last bir index.
Contains index number of last bib index.
#### file .bir/description
#### file .bib/description
#### File .bir/config
#### File .bib/config
```
pack-file.files-until-size.mb=100
@ -177,11 +177,11 @@ pack-file.max-size.mb=1000
## Commands
bir {command} [{arg1} {arg2} {argn}]
bib {command} [{arg1} {arg2} {argn}]
Example:
```
bir clone path=/home/johndoe/mydir url={local path or s3 bucket or FTP server or website url}
bib clone path=/home/johndoe/mydir url={local path or s3 bucket or FTP server or website url}
```
Arguments
@ -196,49 +196,49 @@ Checks for bitrots in current directory
### clone : Cloning a remote repo
```
bir clone {url} [[--bare]] [[revision number|tag]]
bib clone {url} [[--bare]] [[revision number|tag]]
```
#### Local
```
bir clone {path to another local Bir repository - path to directory}
bib clone {path to another local Bib repository - path to directory}
```
#### S3
```
bir clone s3://http[s]://{endpoint url}/{bucket name}
bib clone s3://http[s]://{endpoint url}/{bucket name}
```
Then you will be asked for access key and secret key.
#### FTP/FTPS/SFTP
```
bir clone {protocol}://[{user}:{password}]@{host url}:{port}/{directory}
bib clone {protocol}://[{user}:{password}]@{host url}:{port}/{directory}
```
#### HTTP/HTTPS
```
bir clone http[s]://[{user}:{password}]@{host url}:{port}/{directory}
bib clone http[s]://[{user}:{password}]@{host url}:{port}/{directory}
```
#### Bir server (via Rest api)
#### Bib server (via Rest api)
```
bir clone bir:://[{user}:{password}]@{host url}:{port}/[path to repository/]{repository name}
bib clone bib:://[{user}:{password}]@{host url}:{port}/[path to repository/]{repository name}
```
### init
Init commands creates new directory .bir with its structure
Init commands creates new directory .bib with its structure
```
bir init [[--bare]]
bib init [[--bare]]
```
* Creating a new empty Bir repository
* Creating a Bir repository using an existing directory
* Creating a new empty Bib repository
* Creating a Bib repository using an existing directory
### help
@ -257,7 +257,7 @@ bir init [[--bare]]
### blame
```
bir blame {file} {remote}
bib blame {file} {remote}
```
### clean
@ -265,7 +265,7 @@ bir blame {file} {remote}
### gc
```
bir gc abc
bib gc abc
```
### fsck
@ -277,13 +277,13 @@ bir gc abc
### remote add {remote name}
```
bir remote add {remote name}
bib remote add {remote name}
```
```
bir remote add abc protocol://user:pw|{}@host:port/directory[::password=encryption_password|{}::duplicate_count=1::exclude=::include=::]
bir remote add wedos_disk_100gb_backup user:pw@host:port/directory::password=123::duplicate_count=2
bir remote add abc user:pw|{}@host:port/directory::password=encryption_password|{}::duplicate_count={1, 0 is default}::compression_level={0-9,5 is default}
bib remote add abc protocol://user:pw|{}@host:port/directory[::password=encryption_password|{}::duplicate_count=1::exclude=::include=::]
bib remote add wedos_disk_100gb_backup user:pw@host:port/directory::password=123::duplicate_count=2
bib remote add abc user:pw|{}@host:port/directory::password=encryption_password|{}::duplicate_count={1, 0 is default}::compression_level={0-9,5 is default}
```
{} placeholders means, that user will be asked in console (to avoid the password to be in console history)
@ -291,41 +291,41 @@ bir remote add abc user:pw|{}@host:port/directory::password=encryption_password|
### remote remove {remote name}
```
bir remote remove abc
bib remote remove abc
```
### bir commit
### bib commit
```
bir commit [-m "{message}"]
bib commit [-m "{message}"]
```
### bir mirror {remote name}
### bib mirror {remote name}
```
bir mirror abc def ghi [-m message -t TAG]
bir mirror @all
bib mirror abc def ghi [-m message -t TAG]
bib mirror @all
```
### bir fetch
### bib fetch
### bir pull
### bib pull
### bir log
### bib log
### bir diff
### bib diff
### bir prune
### bib prune
```
bir prune origin --since 2021-10-04
bir prune abc --since "2 months ago" | 10 … does not delete anything, only marks objects to be deleted
bib prune origin --since 2021-10-04
bib prune abc --since "2 months ago" | 10 … does not delete anything, only marks objects to be deleted
```
### verify
```
bir verify abc
bib verify abc
```
### repack

14
pom.xml
View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
bit-inspector: Tool detecting bit rots in files.
bit-backup: Tool detecting bit rots in files.
Copyright (C) 2016-2022 the original author or authors.
This program is free software; you can redistribute it and/or
@ -25,15 +25,15 @@
<parent>
<groupId>org.nanoboot.essential</groupId>
<artifactId>nanoboot-parent</artifactId>
<version>0.1.1</version>
<version>0.1.1-SNAPSHOT</version>
</parent>
<groupId>org.nanoboot.tools</groupId>
<artifactId>bit-inspector</artifactId>
<artifactId>bit-backup</artifactId>
<version>0.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Bit Inspector</name>
<name>Bit Backup</name>
<description>Tool detecting bit rots in files.</description>
<properties>
@ -81,7 +81,7 @@
<configuration>
<archive>
<manifest>
<mainClass>org.nanoboot.bitinspector.core.Main</mainClass>
<mainClass>org.nanoboot.bitbackup.core.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
@ -121,8 +121,8 @@
<configuration>
<resources>
<resource>
<directory>src/main/resources/db_migrations/sqlite/bitinspector</directory>
<targetPath>db_migrations/sqlite/bitinspector</targetPath>
<directory>src/main/resources/db_migrations/sqlite/bitbackup</directory>
<targetPath>db_migrations/sqlite/bitbackup</targetPath>
<includes>
<include>*.sql</include>
</includes>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////
// bit-inspector: Tool detecting bit rots in files.
// bit-backup: Tool detecting bit rots in files.
// Copyright (C) 2016-2022 the original author or authors.
//
// This program is free software; you can redistribute it and/or
@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
///////////////////////////////////////////////////////////////////////////////////////////////
module bitinspector {
module bitbackup {
requires org.apache.commons.io;
requires lombok;
requires org.apache.logging.log4j;

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////
// bit-inspector: Tool detecting bit rots in files.
// bit-backup: Tool detecting bit rots in files.
// Copyright (C) 2023-2023 the original author or authors.
//
// This program is free software; you can redistribute it and/or
@ -16,36 +16,37 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
///////////////////////////////////////////////////////////////////////////////////////////////
package org.nanoboot.bitinspector.commands;
package org.nanoboot.bitbackup.commands;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;
import java.util.regex.Pattern;
import org.nanoboot.bitinspector.core.Utils;
import org.nanoboot.bitbackup.core.Utils;
/**
*
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
* @author <a href="mailto:mail@robertvokac.com">Robert Vokac</a>
*/
public class BirIgnoreRegex implements Predicate<String> {
public class BibIgnoreRegex implements Predicate<String> {
private final List<String> patterns = new ArrayList<>();
public BirIgnoreRegex(File birIgnoreFile) {
public BibIgnoreRegex(File bibIgnoreFile) {
patterns.add(convertUnixRegexToJavaRegex("*.birreport.csv"));
addBirIgnoreFile(birIgnoreFile);
patterns.add(convertUnixRegexToJavaRegex("*.bibreport.csv"));
this.addBibIgnoreFile(bibIgnoreFile);
}
public final void addBirIgnoreFile(File birIgnoreFile) {
addBirIgnoreFile(birIgnoreFile, null);
public final void addBibIgnoreFile(File bibIgnoreFile) {
addBibIgnoreFile(bibIgnoreFile, null);
}
public final void addBirIgnoreFile(File birIgnoreFile, File workingDir) {
String[] lines = birIgnoreFile.exists() ? Utils.readTextFromFile(birIgnoreFile).split("\\R") : new String[]{};
String addPrefix = workingDir == null ? "" : birIgnoreFile.getParentFile().getAbsolutePath().replace(workingDir.getAbsolutePath() + "/", "");
public final void addBibIgnoreFile(File bibIgnoreFile, File workingDir) {
String[] lines = bibIgnoreFile.exists() ? Utils.readTextFromFile(bibIgnoreFile).split("\\R") : new String[]{};
String addPrefix = workingDir == null ? "" : bibIgnoreFile.getParentFile().getAbsolutePath().replace(workingDir.getAbsolutePath() + "/", "");
for (String l : lines) {
if (l.isBlank() || l.trim().startsWith("#")) {

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////
// bit-inspector: Tool detecting bit rots in files.
// bit-backup: Tool detecting bit rots in files.
// Copyright (C) 2023-2023 the original author or authors.
//
// This program is free software; you can redistribute it and/or
@ -16,7 +16,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
///////////////////////////////////////////////////////////////////////////////////////////////
package org.nanoboot.bitinspector.commands;
package org.nanoboot.bitbackup.commands;
import java.io.File;
import java.util.ArrayList;
@ -26,17 +26,18 @@ import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.nanoboot.bitinspector.core.BirContext;
import org.nanoboot.bitinspector.core.Command;
import org.nanoboot.bitinspector.core.BirArgs;
import org.nanoboot.bitinspector.core.BitInspectorException;
import org.nanoboot.bitinspector.core.BirFiles;
import org.nanoboot.bitinspector.core.ListSet;
import org.nanoboot.bitinspector.core.Utils;
import org.nanoboot.bitinspector.entity.FsFile;
import org.nanoboot.bitinspector.entity.SystemItem;
import org.nanoboot.bitinspector.persistence.api.FileRepository;
import org.nanoboot.bitinspector.persistence.impl.sqlite.SqliteDatabaseMigration;
import org.nanoboot.bitbackup.core.BibContext;
import org.nanoboot.bitbackup.core.Command;
import org.nanoboot.bitbackup.core.BibArgs;
import org.nanoboot.bitbackup.core.BitBackupException;
import org.nanoboot.bitbackup.core.BibFiles;
import org.nanoboot.bitbackup.core.Constants;
import org.nanoboot.bitbackup.core.ListSet;
import org.nanoboot.bitbackup.core.Utils;
import org.nanoboot.bitbackup.entity.FsFile;
import org.nanoboot.bitbackup.entity.SystemItem;
import org.nanoboot.bitbackup.persistence.api.FileRepository;
import org.nanoboot.bitbackup.persistence.impl.sqlite.SqliteDatabaseMigration;
import org.nanoboot.dbmigration.core.main.MigrationResult;
import org.nanoboot.powerframework.time.duration.Duration;
import org.nanoboot.powerframework.time.moment.LocalDateTime;
@ -87,31 +88,31 @@ public class CheckCommand implements Command {
static int iStatic = 0;
@Override
public String run(BirArgs birArgs) {
BirFiles birFiles = new BirFiles(birArgs);
BirContext birContext = new BirContext(birFiles.getWorkingDirAbsolutePath());
public String run(BibArgs bibArgs) {
BibFiles bibFiles = new BibFiles(bibArgs);
BibContext bibContext = new BibContext(bibFiles.getWorkingDirAbsolutePath());
//
//part 1:
part1CheckDbHasExpectedHashSum(birFiles);
part1CheckDbHasExpectedHashSum(bibFiles);
//part 2:
boolean part2Result = part2MigrateDbSchemaIfNeeded(birFiles);
if(!part2Result) {
boolean part2Result = part2MigrateDbSchemaIfNeeded(bibFiles);
if (!part2Result) {
return "part 2 failed";
}
//part 3:
part3UpdateVersionInDbIfNeeded(birContext);
part3UpdateVersionInDbIfNeeded(bibContext);
ListSet<File> filesInFileSystem = part4FoundFilesInFileSystem(birFiles, birArgs);
ListSet<FsFile> filesInDb = part5FoundFilesInDb(birContext.getFileRepository(), birArgs);
ListSet<File> filesInFileSystem = part4FoundFilesInFileSystem(bibFiles, bibArgs);
ListSet<FsFile> filesInDb = part5FoundFilesInDb(bibContext.getFileRepository(), bibArgs);
LocalDateTime now = part6AddNewFilesToDb(filesInFileSystem, birFiles, filesInDb, birContext);
LocalDateTime now = part6AddNewFilesToDb(filesInFileSystem, bibFiles, filesInDb, bibContext);
List<FsFile> filesToBeRemovedFromDb = part7RemoveDeletedFilesFromDb(filesInDb, filesInFileSystem, birContext);
List<FsFile> filesToBeRemovedFromDb = part7RemoveDeletedFilesFromDb(filesInDb, filesInFileSystem, bibContext);
List<FsFile> filesWithBitRot = part8CompareContentAndLastModificationDate(filesInDb, filesToBeRemovedFromDb, birContext, now);
List<FsFile> filesWithBitRot = part8CompareContentAndLastModificationDate(filesInDb, filesToBeRemovedFromDb, bibContext, now);
part9CreateReportCsvIfNeeded(birArgs, birFiles, filesWithBitRot);
part10CalculateCurrentHashSumOfDbFile(birFiles);
part9CreateReportCsvIfNeeded(bibArgs, bibFiles, filesWithBitRot);
part10CalculateCurrentHashSumOfDbFile(bibFiles);
LOG.info("==========");
LOG.info("Summary");
@ -134,17 +135,32 @@ public class CheckCommand implements Command {
/**
* Checks, if SQLite DB file has the expected SHA-512 hash sum
*
* @param birSQLite3File
* @param birSQLite3FileSha512
* @throws BitInspectorException - if this check fails.
* @param bibSQLite3File
* @param bibSQLite3FileSha512
* @throws BitBackupException - if this check fails.
*/
private void part1CheckDbHasExpectedHashSum(BirFiles birInspectorFiles) throws BitInspectorException {
private void part1CheckDbHasExpectedHashSum(BibFiles bitBackupFiles) throws BitBackupException {
LOG.info("** Part {}: Checking DB, if has expected check sum.", CheckCommandPart.CHECK_OLD_DB_CHECKSUM.number);
final boolean dbExists = birInspectorFiles.getBirSQLite3File().exists();
final boolean checkSumExists = birInspectorFiles.getBirSQLite3FileSha512().exists();
final File bibSQLite3File = bitBackupFiles.getBibSQLite3File();
final File birSQLite3File = bitBackupFiles.getBirSQLite3File();
final File bibSQLite3FileSha512 = bitBackupFiles.getBibSQLite3FileSha512();
final File birSQLite3FileSha512 = bitBackupFiles.getBirSQLite3FileSha512();
if (Constants.MIGRATE_FROM_BIT_INSPECTOR_TO_BIT_BACKUP_IF_NEEDED && !bibSQLite3File.exists() && birSQLite3File.exists()) {
//apply for migration to Bit Backup
birSQLite3File.renameTo(bibSQLite3File);
if (!bibSQLite3FileSha512.exists() && birSQLite3FileSha512.exists()) {
//apply for migration to Bit Backup
birSQLite3FileSha512.renameTo(bibSQLite3FileSha512);
}
}
final boolean dbExists = bitBackupFiles.getBibSQLite3File().exists();
final boolean checkSumExists = bitBackupFiles.getBibSQLite3FileSha512().exists();
if (dbExists && checkSumExists) {
String expectedHash = Utils.readTextFromFile(birInspectorFiles.getBirSQLite3FileSha512());
String returnedHash = Utils.calculateSHA512Hash(birInspectorFiles.getBirSQLite3File());
String expectedHash = Utils.readTextFromFile(bibSQLite3FileSha512);
String returnedHash = Utils.calculateSHA512Hash(bitBackupFiles.getBibSQLite3File());
if (!returnedHash.equals(expectedHash)) {
String msg
= "Part {}: KO. "
@ -153,10 +169,10 @@ public class CheckCommand implements Command {
+ ". Expected SHA-512 hash sum was: "
+ expectedHash
+ " for file "
+ birInspectorFiles.getBirSQLite3File().getAbsolutePath();
+ bitBackupFiles.getBibSQLite3File().getAbsolutePath();
LOG.error(msg, CheckCommandPart.CHECK_OLD_DB_CHECKSUM.number);
LOG.info("Exiting because of the previous error.");
throw new BitInspectorException(msg);
throw new BitBackupException(msg);
}
} else {
LOG.info("Part {}: OK. Nothing to do: {}",
@ -165,11 +181,11 @@ public class CheckCommand implements Command {
}
}
private boolean part2MigrateDbSchemaIfNeeded(BirFiles birFiles) {
private boolean part2MigrateDbSchemaIfNeeded(BibFiles bibFiles) {
LOG.info("** Part {}: Migrating schema, if needed.", CheckCommandPart.MIGRATE_DB_SCHEMA_IF_NEEDED.number);
try {
MigrationResult migrationResult = SqliteDatabaseMigration.getInstance().migrate(birFiles.getWorkingDirAbsolutePath());
MigrationResult migrationResult = SqliteDatabaseMigration.getInstance().migrate(bibFiles.getWorkingDirAbsolutePath());
if (migrationResult == MigrationResult.SUCCESS) {
LOG.info("Part {}: OK. Success.", CheckCommandPart.MIGRATE_DB_SCHEMA_IF_NEEDED.number);
return true;
@ -183,29 +199,39 @@ public class CheckCommand implements Command {
}
}
private void part3UpdateVersionInDbIfNeeded(BirContext birContext) {
private void part3UpdateVersionInDbIfNeeded(BibContext bibContext) {
LOG.info("** Part {}: Updating version, if needed.", CheckCommandPart.UPDATE_VERSION.number);
String version = birContext.getSystemItemRepository().read("bir.version").getValue();
System.out.println("Before: bir.version=" + version);
if (version == null) {
birContext.getSystemItemRepository().create(new SystemItem("bir.version", "0.0.0-SNAPSHOT"));
if(Constants.MIGRATE_FROM_BIT_INSPECTOR_TO_BIT_BACKUP_IF_NEEDED){
//Migrating from bit-inspector to bit-backup:
String birVersion = bibContext.getSystemItemRepository().read("bir.version").getValue();
if (birVersion != null) {
bibContext.getSystemItemRepository().remove(BIRVERSION);
}
}
String bibVersion = bibContext.getSystemItemRepository().read(BIBVERSION).getValue();
System.out.println("Before: bib.version=" + bibVersion);
if (bibVersion == null) {
bibContext.getSystemItemRepository().create(new SystemItem("bib.version", "0.0.0-SNAPSHOT"));
}
System.out.println("Updating version in DB.");
version = birContext.getSystemItemRepository().read("bir.version").getValue();
System.out.println("After: bir.version=" + version);
bibVersion = bibContext.getSystemItemRepository().read("bib.version").getValue();
System.out.println("After: bib.version=" + bibVersion);
LOG.info("Part {}: OK.", CheckCommandPart.UPDATE_VERSION.number);
}
public static final String BIBVERSION = "bib.version";
public static final String BIRVERSION = "bir.version";
private ListSet<File> part4FoundFilesInFileSystem(BirFiles birFiles, BirArgs birArgs) {
private ListSet<File> part4FoundFilesInFileSystem(BibFiles bibFiles, BibArgs bibArgs) {
LOG.info("** Part {}: Loading files in filesystem", CheckCommandPart.FOUND_FILES_IN_FILESYSTEM.number);
String workingDir = birFiles.getWorkingDirAbsolutePath();
String workingDir = bibFiles.getWorkingDirAbsolutePath();
List<File> filesAlreadyFound = new ArrayList<>();
List<File> filesInDirList = foundFilesInCurrentDir(birFiles.getWorkingDir(), filesAlreadyFound, birFiles);
List<File> filesInDirList = foundFilesInCurrentDir(bibFiles.getWorkingDir(), filesAlreadyFound, bibFiles);
ListSet<File> listSet = new ListSet<>(filesInDirList, f -> loadPathButOnlyTheNeededPart(birFiles.getWorkingDir(), f));
ListSet<File> listSet = new ListSet<>(filesInDirList, f -> loadPathButOnlyTheNeededPart(bibFiles.getWorkingDir(), f));
LOG.info("Part {}: Found {} files.", CheckCommandPart.FOUND_FILES_IN_FILESYSTEM.number, listSet.size());
if (birArgs.isVerboseLoggingEnabled()) {
if (bibArgs.isVerboseLoggingEnabled()) {
filesInDirList.stream().forEach((f -> LOG.info("#" + (++iStatic) + " " + f.getAbsolutePath().substring(workingDir.length() + 1))));
}
return listSet;
@ -219,28 +245,40 @@ public class CheckCommand implements Command {
private int foundFiles;
private int foundDirs;
private List<File> foundFilesInCurrentDir(File currentDir, List<File> filesAlreadyFound, BirFiles birFiles) {
private List<File> foundFilesInCurrentDir(File currentDir, List<File> filesAlreadyFound, BibFiles bibFiles) {
for (File f : currentDir.listFiles()) {
boolean isAlsoBirIgnore =f.getName().equals(birFiles.getBirIgnore().getName());
if(isAlsoBirIgnore && !f.getAbsolutePath().equals(birFiles.getBirIgnore().getAbsoluteFile())) {
birFiles.getBirIgnoreRegex().addBirIgnoreFile(f, birFiles.getWorkingDir());
if(Constants.MIGRATE_FROM_BIT_INSPECTOR_TO_BIT_BACKUP_IF_NEEDED) {
//Migrating from bit-inspector to bit-backup:
boolean isAlsoBirIgnore = f.getName().equals(bibFiles.getBirIgnore().getName());
if(isAlsoBirIgnore) {
File bibIgnoreFile = new File(f.getParentFile(), bibFiles.getBibIgnore().getName());
if(!bibIgnoreFile.exists()) {
f.renameTo(bibIgnoreFile);
}
}
}
boolean isAlsoBibIgnore = f.getName().equals(bibFiles.getBibIgnore().getName());
if (isAlsoBibIgnore && !f.getAbsolutePath().equals(bibFiles.getBibIgnore().getAbsoluteFile())) {
bibFiles.getBibIgnoreRegex().addBibIgnoreFile(f, bibFiles.getWorkingDir());
}
if (f.isDirectory()) {
++foundDirs;
foundFilesInCurrentDir(f, filesAlreadyFound, birFiles);
foundFilesInCurrentDir(f, filesAlreadyFound, bibFiles);
} else {
++foundFiles;
if (f.getAbsolutePath().equals(birFiles.getBirSQLite3File().getAbsolutePath())) {
if (f.getAbsolutePath().equals(bibFiles.getBirSQLite3File().getAbsolutePath())) {
continue;
}
if (f.getAbsolutePath().equals(birFiles.getBirSQLite3FileSha512().getAbsolutePath())) {
if (f.getAbsolutePath().equals(bibFiles.getBirSQLite3FileSha512().getAbsolutePath())) {
continue;
}
++iii;
//System.out.println("Testing file: " + iii + "#" + " " + loadPathButOnlyTheNeededPart(currentDirRoot, f));
if (birFiles.getBirIgnoreRegex().test(loadPathButOnlyTheNeededPart(birFiles.getWorkingDir(), f))) {
if (bibFiles.getBibIgnoreRegex().test(loadPathButOnlyTheNeededPart(bibFiles.getWorkingDir(), f))) {
continue;
}
filesAlreadyFound.add(f);
@ -249,20 +287,20 @@ public class CheckCommand implements Command {
return filesAlreadyFound;
}
private ListSet<FsFile> part5FoundFilesInDb(FileRepository fileRepository, BirArgs birArgs) {
private ListSet<FsFile> part5FoundFilesInDb(FileRepository fileRepository, BibArgs bibArgs) {
LOG.info("** Part {}: Loading files in DB", CheckCommandPart.FOUND_FILES_IN_DB.number);
List<FsFile> filesInDb = fileRepository.list();
ListSet<FsFile> listSet = new ListSet<>(filesInDb, f -> f.getAbsolutePath());
LOG.info("Part {}: Found {} files.", CheckCommandPart.FOUND_FILES_IN_DB.number, listSet.size());
iStatic = 0;
if (birArgs.isVerboseLoggingEnabled()) {
if (bibArgs.isVerboseLoggingEnabled()) {
filesInDb.stream().forEach((f -> System.out.println("#" + (++iStatic) + " " + f.toString())));
}
return listSet;
}
private LocalDateTime part6AddNewFilesToDb(ListSet<File> filesInFileSystem, BirFiles birFiles, ListSet<FsFile> filesInDb, BirContext birContext) {
private LocalDateTime part6AddNewFilesToDb(ListSet<File> filesInFileSystem, BibFiles bibFiles, ListSet<FsFile> filesInDb, BibContext bibContext) {
LOG.info("** Part {}: Adding new files to DB", CheckCommandPart.ADD_NEW_FILES_TO_DB.number);
Date lastChecked = new Date();
org.nanoboot.powerframework.time.moment.LocalDateTime now = org.nanoboot.powerframework.time.moment.LocalDateTime.convertJavaUtilDateToPowerLocalDateTime(lastChecked);
@ -279,7 +317,7 @@ public class CheckCommand implements Command {
String.format("%,.2f", progress));
}
String absolutePathOfFileInDir = loadPathButOnlyTheNeededPart(birFiles.getWorkingDir(), fileInDir);
String absolutePathOfFileInDir = loadPathButOnlyTheNeededPart(bibFiles.getWorkingDir(), fileInDir);
if (!filesInDb.doesSetContains(absolutePathOfFileInDir)) {
Date lastModified = new Date(fileInDir.lastModified());
org.nanoboot.powerframework.time.moment.LocalDateTime ldt = org.nanoboot.powerframework.time.moment.LocalDateTime.convertJavaUtilDateToPowerLocalDateTime(lastModified);
@ -300,11 +338,11 @@ public class CheckCommand implements Command {
}
LOG.info("Adding new files: {}", filesMissingInDb.size());
birContext.getFileRepository().create(filesMissingInDb);
bibContext.getFileRepository().create(filesMissingInDb);
return now;
}
private List<FsFile> part7RemoveDeletedFilesFromDb(ListSet<FsFile> filesInDb, ListSet<File> filesInFileSystem, BirContext birContext) {
private List<FsFile> part7RemoveDeletedFilesFromDb(ListSet<FsFile> filesInDb, ListSet<File> filesInFileSystem, BibContext bibContext) {
LOG.info("** Part {}: Removing deleted files from DB", CheckCommandPart.REMOVE_DELETED_FILES_FROM_DB.number);
List<FsFile> filesToBeRemovedFromDb = new ArrayList<>();
int processedCount = 0;
@ -333,13 +371,13 @@ public class CheckCommand implements Command {
CheckCommandPart.REMOVE_DELETED_FILES_FROM_DB.number,
filesToBeRemovedFromDb.size());
for (FsFile f : filesToBeRemovedFromDb) {
birContext.getFileRepository().remove(f);
bibContext.getFileRepository().remove(f);
}
return filesToBeRemovedFromDb;
}
private List<FsFile> part8CompareContentAndLastModificationDate(
ListSet<FsFile> filesInDb, List<FsFile> filesToBeRemovedFromDb, BirContext birContext, LocalDateTime now) {
ListSet<FsFile> filesInDb, List<FsFile> filesToBeRemovedFromDb, BibContext bibContext, LocalDateTime now) {
LOG.info("** Part {}: Comparing Content and last modification date", CheckCommandPart.COMPARE_CONTENT_AND_LAST_MODTIME.number);
double countOfFilesToCalculateHashSum = filesInDb.size() - filesToBeRemovedFromDb.size();
int processedCount = 0;
@ -368,13 +406,12 @@ public class CheckCommand implements Command {
Date lastModified = new Date(file.lastModified());
org.nanoboot.powerframework.time.moment.LocalDateTime ldt = org.nanoboot.powerframework.time.moment.LocalDateTime.convertJavaUtilDateToPowerLocalDateTime(lastModified);
String calculatedHash = Utils.calculateSHA512Hash(file);
if (ldt.toString().equals(fileInDb.getLastModificationDate()) && !calculatedHash.equals(fileInDb.getHashSumValue())) {
filesWithBitRot.add(fileInDb);
fileInDb.setLastCheckDate(now.toString());
fileInDb.setLastCheckResult("KO");
birContext.getFileRepository().updateFile(fileInDb);
bibContext.getFileRepository().updateFile(fileInDb);
continue;
}
if (!ldt.toString().equals(fileInDb.getLastModificationDate())) {
@ -384,7 +421,7 @@ public class CheckCommand implements Command {
fileInDb.setHashSumAlgorithm("SHA-512");
fileInDb.setSize(file.length());
fileInDb.setLastCheckResult("OK");
birContext.getFileRepository().updateFile(fileInDb);
bibContext.getFileRepository().updateFile(fileInDb);
//System.out.println(fileInDb.toString());
contentAndModTimeWereChanged++;
continue;
@ -394,7 +431,7 @@ public class CheckCommand implements Command {
if (fileInDb.getSize() == 0) {
fileInDb.setSize(file.length());
birContext.getFileRepository().updateFile(fileInDb);
bibContext.getFileRepository().updateFile(fileInDb);
} else {
filesToUpdateLastCheckDate.add(fileInDb);
}
@ -411,30 +448,30 @@ public class CheckCommand implements Command {
LOG.info("Part {}: Updating files - content and last modification date were not changed): {}",
CheckCommandPart.COMPARE_CONTENT_AND_LAST_MODTIME.number,
filesToUpdateLastCheckDate.size());
birContext.getFileRepository().updateLastCheckDate(now.toString(), filesToUpdateLastCheckDate);
bibContext.getFileRepository().updateLastCheckDate(now.toString(), filesToUpdateLastCheckDate);
return filesWithBitRot;
}
private void part9CreateReportCsvIfNeeded(BirArgs birArgs, BirFiles birFiles, List<FsFile> filesWithBitRot) {
private void part9CreateReportCsvIfNeeded(BibArgs bibArgs, BibFiles bibFiles, List<FsFile> filesWithBitRot) {
LOG.info("** Part {}: Creating csv report, if needed", CheckCommandPart.CREATE_REPORT_CSV_IF_NEEDED.number);
if (!birArgs.hasArgument("report")) {
if (!bibArgs.hasArgument("report")) {
LOG.info(" Part {}: OK. Nothing to do. No option report was passed.", CheckCommandPart.CREATE_REPORT_CSV_IF_NEEDED.number);
return;
}
if (!birArgs.getArgument("report").equals("true")) {
if (!bibArgs.getArgument("report").equals("true")) {
LOG.info("Part {}: Nothing to do. Option report={}",
CheckCommandPart.CREATE_REPORT_CSV_IF_NEEDED.number,
birArgs.getArgument("report"));
bibArgs.getArgument("report"));
return;
}
File birReportCsv = birFiles.getBirReportCsv();
if (birReportCsv.exists()) {
File bibReportCsv = bibFiles.getBibReportCsv();
if (bibReportCsv.exists()) {
Long nowLong = org.nanoboot.powerframework.time.moment.UniversalDateTime.now().toLong();
File backup = new File(birReportCsv.getParentFile().getAbsolutePath() + "/" + nowLong + "." + birReportCsv.getName());
birReportCsv.renameTo(backup);
File backup = new File(bibReportCsv.getParentFile().getAbsolutePath() + "/" + nowLong + "." + bibReportCsv.getName());
bibReportCsv.renameTo(backup);
}
StringBuilder sb = new StringBuilder();
@ -449,14 +486,14 @@ public class CheckCommand implements Command {
.append(Utils.calculateSHA512Hash(new File("./" + f.getAbsolutePath())))
.append("\n")
);
Utils.writeTextToFile(sb.toString(), birReportCsv);
Utils.writeTextToFile(sb.toString(), bibReportCsv);
LOG.info("Part {}: OK.",
CheckCommandPart.CREATE_REPORT_CSV_IF_NEEDED.number);
}
private void part10CalculateCurrentHashSumOfDbFile(BirFiles birFiles) {
private void part10CalculateCurrentHashSumOfDbFile(BibFiles bibFiles) {
LOG.info("** Part {}: Calculating current hash sum of DB file", CheckCommandPart.CHECK_NEW_DB_CHECKSUM.number);
Utils.writeTextToFile(Utils.calculateSHA512Hash(birFiles.getBirSQLite3File()), birFiles.getBirSQLite3FileSha512());
Utils.writeTextToFile(Utils.calculateSHA512Hash(bibFiles.getBirSQLite3File()), bibFiles.getBirSQLite3FileSha512());
}
}

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////
// bit-inspector: Tool detecting bit rots in files.
// bit-backup: Tool detecting bit rots in files.
// Copyright (C) 2023-2023 the original author or authors.
//
// This program is free software; you can redistribute it and/or
@ -16,14 +16,14 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
///////////////////////////////////////////////////////////////////////////////////////////////
package org.nanoboot.bitinspector.commands;
package org.nanoboot.bitbackup.commands;
import org.nanoboot.bitinspector.core.Command;
import org.nanoboot.bitinspector.core.BirArgs;
import org.nanoboot.bitbackup.core.Command;
import org.nanoboot.bitbackup.core.BibArgs;
/**
*
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
* @author <a href="mailto:mail@robertvokac.com">Robert Vokac</a>
*/
public class HelpCommand implements Command {
@ -38,14 +38,14 @@ public class HelpCommand implements Command {
}
@Override
public String run(BirArgs bitInspectorArgs) {
public String run(BibArgs bitInspectorArgs) {
String str = """
NAME
bir - " Bit Inspector"
bib - " Bit Backup"
SYNOPSIS
bir [command] [options]
If no command is provided, then the default command check is used. This means, if you run "bit-inspector", it is the same, as to run "bir check".
bib [command] [options]
If no command is provided, then the default command check is used. This means, if you run "bit-backup", it is the same, as to run "bib check".
DESCRIPTION
Detects bit rotten files in the given directory to keep your files forever.
@ -56,7 +56,7 @@ public class HelpCommand implements Command {
dir={working directory to be checked for bit rot}
Optional. Default=. (current working directory)
report=true or false
Optional. Default= false (nothing will be reported to file .birreport.csv).
Optional. Default= false (nothing will be reported to file .bibreport.csv).
help Display help information
version Display version information
""";

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////
// bit-inspector: Tool detecting bit rots in files.
// bit-backup: Tool detecting bit rots in files.
// Copyright (C) 2023-2023 the original author or authors.
//
// This program is free software; you can redistribute it and/or
@ -17,16 +17,16 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
///////////////////////////////////////////////////////////////////////////////////////////////
package org.nanoboot.bitinspector.commands;
package org.nanoboot.bitbackup.commands;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.nanoboot.bitinspector.core.Command;
import org.nanoboot.bitinspector.core.BirArgs;
import org.nanoboot.bitbackup.core.Command;
import org.nanoboot.bitbackup.core.BibArgs;
/**
*
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
* @author <a href="mailto:mail@robertvokac.com">Robert Vokac</a>
*/
public class VersionCommand implements Command {
@ -41,8 +41,8 @@ private static final Logger LOG = LogManager.getLogger(VersionCommand.class);
}
@Override
public String run(BirArgs bitInspectorArgs) {
String result = "Bit Inspector 0.0.0-SNAPSHOT";
public String run(BibArgs bitInspectorArgs) {
String result = "Bit Backup 0.0.0-SNAPSHOT";
LOG.info(result);
return result;
}

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////
// bit-inspector: Tool detecting bit rots in files.
// bit-backup: Tool detecting bit rots in files.
// Copyright (C) 2023-2023 the original author or authors.
//
// This program is free software; you can redistribute it and/or
@ -16,7 +16,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
///////////////////////////////////////////////////////////////////////////////////////////////
package org.nanoboot.bitinspector.core;
package org.nanoboot.bitbackup.core;
import java.util.HashMap;
import java.util.Map;
@ -24,9 +24,9 @@ import lombok.Getter;
/**
*
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
* @author <a href="mailto:mail@robertvokac.com">Robert Vokac</a>
*/
public class BirArgs {
public class BibArgs {
@Getter
private final String command;
@ -42,15 +42,15 @@ public class BirArgs {
return array;
}
public BirArgs(BitInspectorCommand command, Map<String, String> map) {
public BibArgs(BitInspectorCommand command, Map<String, String> map) {
this(convertToStringArray(command.name().toLowerCase(), map));
}
public BirArgs(String command, Map<String, String> map) {
public BibArgs(String command, Map<String, String> map) {
this(convertToStringArray(command, map));
}
public BirArgs(String[] args) {
public BibArgs(String[] args) {
command = args.length == 0 ? "check" : args[0];
if (args.length > 1) {

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////
// bit-inspector: Tool detecting bit rots in files.
// bit-backup: Tool detecting bit rots in files.
// Copyright (C) 2023-2023 the original author or authors.
//
// This program is free software; you can redistribute it and/or
@ -17,21 +17,21 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
///////////////////////////////////////////////////////////////////////////////////////////////
package org.nanoboot.bitinspector.core;
package org.nanoboot.bitbackup.core;
import lombok.Getter;
import org.nanoboot.bitinspector.persistence.api.ConnectionFactory;
import org.nanoboot.bitinspector.persistence.api.FileRepository;
import org.nanoboot.bitinspector.persistence.api.SystemItemRepository;
import org.nanoboot.bitinspector.persistence.impl.sqlite.FileRepositoryImplSqlite;
import org.nanoboot.bitinspector.persistence.impl.sqlite.SqliteConnectionFactory;
import org.nanoboot.bitinspector.persistence.impl.sqlite.SystemItemRepositoryImplSqlite;
import org.nanoboot.bitbackup.persistence.api.ConnectionFactory;
import org.nanoboot.bitbackup.persistence.api.FileRepository;
import org.nanoboot.bitbackup.persistence.api.SystemItemRepository;
import org.nanoboot.bitbackup.persistence.impl.sqlite.FileRepositoryImplSqlite;
import org.nanoboot.bitbackup.persistence.impl.sqlite.SqliteConnectionFactory;
import org.nanoboot.bitbackup.persistence.impl.sqlite.SystemItemRepositoryImplSqlite;
/**
*
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
* @author <a href="mailto:mail@robertvokac.com">Robert Vokac</a>
*/
public class BirContext {
public class BibContext {
private final String directoryWhereSqliteFileIs;
private ConnectionFactory connectionFactory;
@Getter
@ -39,7 +39,7 @@ public class BirContext {
@Getter
private FileRepository fileRepository;
public BirContext(String directoryWhereSqliteFileIs) {
public BibContext(String directoryWhereSqliteFileIs) {
this.directoryWhereSqliteFileIs = directoryWhereSqliteFileIs;
this.connectionFactory = new SqliteConnectionFactory(directoryWhereSqliteFileIs);
systemItemRepository = new SystemItemRepositoryImplSqlite((SqliteConnectionFactory) connectionFactory);

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////
// bit-inspector: Tool detecting bit rots in files.
// bit-backup: Tool detecting bit rots in files.
// Copyright (C) 2023-2023 the original author or authors.
//
// This program is free software; you can redistribute it and/or
@ -16,37 +16,48 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
///////////////////////////////////////////////////////////////////////////////////////////////
package org.nanoboot.bitinspector.core;
package org.nanoboot.bitbackup.core;
import java.io.File;
import lombok.Data;
import lombok.Getter;
import org.nanoboot.bitinspector.commands.BirIgnoreRegex;
import org.nanoboot.bitbackup.commands.BibIgnoreRegex;
/**
*
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
* @author <a href="mailto:mail@robertvokac.com">Robert Vokac</a>
*/
@Data
@Getter
public class BirFiles {
public class BibFiles {
private final File workingDir;
private final String workingDirAbsolutePath;
private final File bibSQLite3File;
private final File bibSQLite3FileSha512;
private final File bibIgnore;
private final BibIgnoreRegex bibIgnoreRegex;
private final File bibReportCsv;
@Deprecated
private final File birSQLite3File;
@Deprecated
private final File birSQLite3FileSha512;
@Deprecated
private final File birIgnore;
private final BirIgnoreRegex birIgnoreRegex;
private final File birReportCsv;
public BirFiles(BirArgs bitInspectorArgs) {
public BibFiles(BibArgs bitInspectorArgs) {
workingDir = new File(bitInspectorArgs.hasArgument("dir") ? bitInspectorArgs.getArgument("dir") : ".");
workingDirAbsolutePath = workingDir.getAbsolutePath();
bibSQLite3File = new File(workingDirAbsolutePath + "/.bib.sqlite3");
bibSQLite3FileSha512 = new File(workingDirAbsolutePath + "/.bib.sqlite3.sha512");
bibIgnore = new File(workingDirAbsolutePath + "/.bibignore");
bibIgnoreRegex = new BibIgnoreRegex(bibIgnore);
bibReportCsv = new File(workingDirAbsolutePath + "/.bibreport.csv");
//
birSQLite3File = new File(workingDirAbsolutePath + "/.bir.sqlite3");
birSQLite3FileSha512 = new File(workingDirAbsolutePath + "/.bir.sqlite3.sha512");
birIgnore = new File(workingDirAbsolutePath + "/.birignore");
birIgnoreRegex = new BirIgnoreRegex(birIgnore);
birReportCsv = new File(workingDirAbsolutePath + "/.birreport.csv");
}
}

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////
// bit-inspector: Tool detecting bit rots in files.
// bit-backup: Tool detecting bit rots in files.
// Copyright (C) 2023-2023 the original author or authors.
//
// This program is free software; you can redistribute it and/or
@ -17,23 +17,23 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
///////////////////////////////////////////////////////////////////////////////////////////////
package org.nanoboot.bitinspector.core;
package org.nanoboot.bitbackup.core;
/**
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
* @author <a href="mailto:mail@robertvokac.com">Robert Vokac</a>
* @since 0.0.0
*/
public class BitInspectorException extends RuntimeException {
public class BitBackupException extends RuntimeException {
public BitInspectorException(String msg) {
public BitBackupException(String msg) {
super(msg);
}
public BitInspectorException(String msg, Exception e) {
public BitBackupException(String msg, Exception e) {
super(msg, e);
}
public BitInspectorException(Exception e) {
public BitBackupException(Exception e) {
super(e);
}

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////
// bit-inspector: Tool detecting bit rots in files.
// bit-backup: Tool detecting bit rots in files.
// Copyright (C) 2023-2023 the original author or authors.
//
// This program is free software; you can redistribute it and/or
@ -17,19 +17,19 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
///////////////////////////////////////////////////////////////////////////////////////////////
package org.nanoboot.bitinspector.core;
package org.nanoboot.bitbackup.core;
import java.util.HashSet;
import java.util.Set;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.nanoboot.bitinspector.commands.CheckCommand;
import org.nanoboot.bitinspector.commands.HelpCommand;
import org.nanoboot.bitinspector.commands.VersionCommand;
import org.nanoboot.bitbackup.commands.CheckCommand;
import org.nanoboot.bitbackup.commands.HelpCommand;
import org.nanoboot.bitbackup.commands.VersionCommand;
/**
*
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
* @author <a href="mailto:mail@robertvokac.com">Robert Vokac</a>
*/
public class BitInspector {
@ -44,11 +44,11 @@ public class BitInspector {
}
public void run(String[] args) {
run(new BirArgs(args));
run(new BibArgs(args));
}
public void run(BirArgs bitInspectorArgs) {
String command = bitInspectorArgs.getCommand();
public void run(BibArgs bitBackupArgs) {
String command = bitBackupArgs.getCommand();
Command foundCommand = null;
for(Command e:commandImplementations) {
if(e.getName().equals(command)) {
@ -60,10 +60,10 @@ public class BitInspector {
String msg = "Command \"" + command + "\" is not supported.";
LOG.error(msg);
new HelpCommand().run(bitInspectorArgs);
throw new BitInspectorException(msg);
new HelpCommand().run(bitBackupArgs);
throw new BitBackupException(msg);
}
foundCommand.run(bitInspectorArgs);
foundCommand.run(bitBackupArgs);
}
}

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////
// bit-inspector: Tool detecting bit rots in files.
// bit-backup: Tool detecting bit rots in files.
// Copyright (C) 2023-2023 the original author or authors.
//
// This program is free software; you can redistribute it and/or
@ -17,11 +17,11 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
///////////////////////////////////////////////////////////////////////////////////////////////
package org.nanoboot.bitinspector.core;
package org.nanoboot.bitbackup.core;
/**
*
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
* @author <a href="mailto:mail@robertvokac.com">Robert Vokac</a>
*/
public enum BitInspectorCommand {
CHECK, HELP, VERSION;

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////
// bit-inspector: Tool detecting bit rots in files.
// bit-backup: Tool detecting bit rots in files.
// Copyright (C) 2023-2023 the original author or authors.
//
// This program is free software; you can redistribute it and/or
@ -17,16 +17,16 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
///////////////////////////////////////////////////////////////////////////////////////////////
package org.nanoboot.bitinspector.core;
package org.nanoboot.bitbackup.core;
/**
*
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
* @author <a href="mailto:mail@robertvokac.com">Robert Vokac</a>
*/
public interface Command {
public String getName();
default String run(BirArgs bitInspectorArgs) {
throw new BitInspectorException("Not yet implemented.");
default String run(BibArgs bitInspectorArgs) {
throw new BitBackupException("Not yet implemented.");
}
}

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////
// bit-inspector: Tool detecting bit rots in files.
// bit-backup: Tool detecting bit rots in files.
// Copyright (C) 2023-2023 the original author or authors.
//
// This program is free software; you can redistribute it and/or
@ -17,16 +17,17 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
///////////////////////////////////////////////////////////////////////////////////////////////
package org.nanoboot.bitinspector.core;
package org.nanoboot.bitbackup.core;
import java.text.SimpleDateFormat;
/**
*
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
* @author <a href="mailto:mail@robertvokac.com">Robert Vokac</a>
*/
public class Constants {
public static final SimpleDateFormat YYYYMMDDHHMMSSZ_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ssZ");
public static final boolean MIGRATE_FROM_BIT_INSPECTOR_TO_BIT_BACKUP_IF_NEEDED = System.getProperties().containsKey("allowBirToBibMigrationIfNeeded");
}

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////
// bit-inspector: Tool detecting bit rots in files.
// bit-backup: Tool detecting bit rots in files.
// Copyright (C) 2023-2023 the original author or authors.
//
// This program is free software; you can redistribute it and/or
@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
///////////////////////////////////////////////////////////////////////////////////////////////
package org.nanoboot.bitinspector.core;
package org.nanoboot.bitbackup.core;
import java.util.Collections;
import java.util.Iterator;

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////
// bit-inspector: Tool detecting bit rots in files.
// bit-backup: Tool detecting bit rots in files.
// Copyright (C) 2023-2023 the original author or authors.
//
// This program is free software; you can redistribute it and/or
@ -16,10 +16,10 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
///////////////////////////////////////////////////////////////////////////////////////////////
package org.nanoboot.bitinspector.core;
package org.nanoboot.bitbackup.core;
/**
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
* @author <a href="mailto:mail@robertvokac.com">Robert Vokac</a>
* @since 0.0.0
*/
public class Main {

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////
// bit-inspector: Tool detecting bit rots in files.
// bit-backup: Tool detecting bit rots in files.
// Copyright (C) 2023-2023 the original author or authors.
//
// This program is free software; you can redistribute it and/or
@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
///////////////////////////////////////////////////////////////////////////////////////////////
package org.nanoboot.bitinspector.core;
package org.nanoboot.bitbackup.core;
import dev.mccue.guava.hash.Hashing;
import dev.mccue.guava.io.Files;
@ -39,7 +39,7 @@ import java.util.logging.Logger;
/**
*
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
* @author <a href="mailto:mail@robertvokac.com">Robert Vokac</a>
*/
public class Utils {
@ -82,7 +82,7 @@ public class Utils {
return files;
}
public static void copyFile(File originalFile, File copiedFile) throws BitInspectorException {
public static void copyFile(File originalFile, File copiedFile) throws BitBackupException {
Path originalPath = originalFile.toPath();
Path copied = new File(copiedFile, originalFile.getName()).toPath();
@ -90,7 +90,7 @@ public class Utils {
java.nio.file.Files.copy(originalPath, copied, StandardCopyOption.REPLACE_EXISTING);
} catch (IOException ex) {
ex.printStackTrace();
throw new BitInspectorException("Copying file failed: " + originalFile.getAbsolutePath());
throw new BitBackupException("Copying file failed: " + originalFile.getAbsolutePath());
}
}
@ -100,7 +100,7 @@ public class Utils {
fileWriter = new FileWriter(file);
} catch (IOException ex) {
ex.printStackTrace();
throw new BitInspectorException("Writing to file failed: " + file.getName(), ex);
throw new BitBackupException("Writing to file failed: " + file.getName(), ex);
}
PrintWriter printWriter = new PrintWriter(fileWriter);
printWriter.print(text);
@ -114,7 +114,7 @@ public class Utils {
try {
return new String(java.nio.file.Files.readAllBytes(Paths.get(file.getAbsolutePath())));
} catch (IOException ex) {
throw new BitInspectorException("Reading file failed: " + file.getName(), ex);
throw new BitBackupException("Reading file failed: " + file.getName(), ex);
}
}
@ -124,7 +124,7 @@ public class Utils {
InputStream inputStream = clazz.getResourceAsStream(fileName);
return readFromInputStream(inputStream);
} catch (IOException ex) {
throw new BitInspectorException("Reading file failed: " + fileName, ex);
throw new BitBackupException("Reading file failed: " + fileName, ex);
}
}
@ -169,10 +169,10 @@ public class Utils {
// return hexString;
} catch (IOException ex) {
Logger.getLogger(Utils.class.getName()).log(Level.SEVERE, null, ex);
throw new BitInspectorException(ex);
throw new BitBackupException(ex);
}
}
public static String createJdbcUrl(String directoryWhereSqliteFileIs) {
return "jdbc:sqlite:" + directoryWhereSqliteFileIs + "/" + ".bir.sqlite3?foreign_keys=on;";
return "jdbc:sqlite:" + directoryWhereSqliteFileIs + "/" + ".bib.sqlite3?foreign_keys=on;";
}
}

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////
// bit-inspector: Tool detecting bit rots in files.
// bit-backup: Tool detecting bit rots in files.
// Copyright (C) 2023-2023 the original author or authors.
//
// This program is free software; you can redistribute it and/or
@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
///////////////////////////////////////////////////////////////////////////////////////////////
package org.nanoboot.bitinspector.entity;
package org.nanoboot.bitbackup.entity;
import lombok.AllArgsConstructor;
import lombok.Getter;
@ -26,7 +26,7 @@ import lombok.ToString;
/**
*
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
* @author <a href="mailto:mail@robertvokac.com">Robert Vokac</a>
*/
@Getter
@Setter

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////
// bit-inspector: Tool detecting bit rots in files.
// bit-backup: Tool detecting bit rots in files.
// Copyright (C) 2023-2023 the original author or authors.
//
// This program is free software; you can redistribute it and/or
@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
///////////////////////////////////////////////////////////////////////////////////////////////
package org.nanoboot.bitinspector.entity;
package org.nanoboot.bitbackup.entity;
import lombok.AllArgsConstructor;
import lombok.Getter;
@ -25,7 +25,7 @@ import lombok.Setter;
/**
*
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
* @author <a href="mailto:mail@robertvokac.com">Robert Vokac</a>
*/
@Getter
@Setter

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////
// bit-inspector: Tool detecting bit rots in files.
// bit-backup: Tool detecting bit rots in files.
// Copyright (C) 2023-2023 the original author or authors.
//
// This program is free software; you can redistribute it and/or
@ -16,13 +16,13 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
///////////////////////////////////////////////////////////////////////////////////////////////
package org.nanoboot.bitinspector.persistence.api;
package org.nanoboot.bitbackup.persistence.api;
import java.sql.Connection;
/**
*
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
* @author <a href="mailto:mail@robertvokac.com">Robert Vokac</a>
*/
public interface ConnectionFactory {

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////
// bit-inspector: Tool detecting bit rots in files.
// bit-backup: Tool detecting bit rots in files.
// Copyright (C) 2023-2023 the original author or authors.
//
// This program is free software; you can redistribute it and/or
@ -17,14 +17,14 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
///////////////////////////////////////////////////////////////////////////////////////////////
package org.nanoboot.bitinspector.persistence.api;
package org.nanoboot.bitbackup.persistence.api;
import java.util.List;
import org.nanoboot.bitinspector.entity.FsFile;
import org.nanoboot.bitbackup.entity.FsFile;
/**
*
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
* @author <a href="mailto:mail@robertvokac.com">Robert Vokac</a>
*/
public interface FileRepository {
void create(List<FsFile> files);

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////
// bit-inspector: Tool detecting bit rots in files.
// bit-backup: Tool detecting bit rots in files.
// Copyright (C) 2023-2023 the original author or authors.
//
// This program is free software; you can redistribute it and/or
@ -17,14 +17,14 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
///////////////////////////////////////////////////////////////////////////////////////////////
package org.nanoboot.bitinspector.persistence.api;
package org.nanoboot.bitbackup.persistence.api;
import java.util.List;
import org.nanoboot.bitinspector.entity.SystemItem;
import org.nanoboot.bitbackup.entity.SystemItem;
/**
*
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
* @author <a href="mailto:mail@robertvokac.com">Robert Vokac</a>
*/
public interface SystemItemRepository {
String create(SystemItem systemItem);

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////
// bit-inspector: Tool detecting bit rots in files.
// bit-backup: Tool detecting bit rots in files.
// Copyright (C) 2023-2023 the original author or authors.
//
// This program is free software; you can redistribute it and/or
@ -16,11 +16,11 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
///////////////////////////////////////////////////////////////////////////////////////////////
package org.nanoboot.bitinspector.persistence.impl.sqlite;
package org.nanoboot.bitbackup.persistence.impl.sqlite;
/**
*
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
* @author <a href="mailto:mail@robertvokac.com">Robert Vokac</a>
*/
public class Constants {

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////
// bit-inspector: Tool detecting bit rots in files.
// bit-backup: Tool detecting bit rots in files.
// Copyright (C) 2023-2023 the original author or authors.
//
// This program is free software; you can redistribute it and/or
@ -16,7 +16,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
///////////////////////////////////////////////////////////////////////////////////////////////
package org.nanoboot.bitinspector.persistence.impl.sqlite;
package org.nanoboot.bitbackup.persistence.impl.sqlite;
import java.sql.Connection;
import java.sql.PreparedStatement;
@ -26,12 +26,12 @@ import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.nanoboot.bitinspector.entity.FsFile;
import org.nanoboot.bitinspector.persistence.api.FileRepository;
import org.nanoboot.bitbackup.entity.FsFile;
import org.nanoboot.bitbackup.persistence.api.FileRepository;
/**
*
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
* @author <a href="mailto:mail@robertvokac.com">Robert Vokac</a>
*/
public class FileRepositoryImplSqlite implements FileRepository {

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////
// bit-inspector: Tool detecting bit rots in files.
// bit-backup: Tool detecting bit rots in files.
// Copyright (C) 2023-2023 the original author or authors.
//
// This program is free software; you can redistribute it and/or
@ -16,7 +16,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
///////////////////////////////////////////////////////////////////////////////////////////////
package org.nanoboot.bitinspector.persistence.impl.sqlite;
package org.nanoboot.bitbackup.persistence.impl.sqlite;
import lombok.AllArgsConstructor;
import lombok.Getter;
@ -24,7 +24,7 @@ import lombok.Setter;
/**
*
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
* @author <a href="mailto:mail@robertvokac.com">Robert Vokac</a>
*/
@Getter
@Setter

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////
// bit-inspector: Tool detecting bit rots in files.
// bit-backup: Tool detecting bit rots in files.
// Copyright (C) 2023-2023 the original author or authors.
//
// This program is free software; you can redistribute it and/or
@ -16,17 +16,17 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
///////////////////////////////////////////////////////////////////////////////////////////////
package org.nanoboot.bitinspector.persistence.impl.sqlite;
package org.nanoboot.bitbackup.persistence.impl.sqlite;
import org.nanoboot.bitinspector.persistence.api.ConnectionFactory;
import org.nanoboot.bitbackup.persistence.api.ConnectionFactory;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import org.nanoboot.bitinspector.core.Utils;
import org.nanoboot.bitbackup.core.Utils;
/**
*
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
* @author <a href="mailto:mail@robertvokac.com">Robert Vokac</a>
*/
public class SqliteConnectionFactory implements ConnectionFactory {
private final String jdbcUrl;

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////
// bit-inspector: Tool detecting bit rots in files.
// bit-backup: Tool detecting bit rots in files.
// Copyright (C) 2023-2023 the original author or authors.
//
// This program is free software; you can redistribute it and/or
@ -16,15 +16,15 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
///////////////////////////////////////////////////////////////////////////////////////////////
package org.nanoboot.bitinspector.persistence.impl.sqlite;
package org.nanoboot.bitbackup.persistence.impl.sqlite;
import org.nanoboot.bitinspector.core.Utils;
import org.nanoboot.bitbackup.core.Utils;
import org.nanoboot.dbmigration.core.main.DBMigration;
import org.nanoboot.dbmigration.core.main.MigrationResult;
/**
*
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
* @author <a href="mailto:mail@robertvokac.com">Robert Vokac</a>
*/
public class SqliteDatabaseMigration {
@ -54,8 +54,8 @@ public class SqliteDatabaseMigration {
DBMigration dbMigration = DBMigration
.configure()
.dataSource(jdbcUrl)
.installedBy("bitinspector-persistence-impl-sqlite")
.name("bitinspector")
.installedBy("bitbackup-persistence-impl-sqlite")
.name("bitbackup")
.sqlDialect("sqlite", "org.nanoboot.dbmigration.core.persistence.impl.sqlite.DBMigrationPersistenceSqliteImpl")
.sqlMigrationsClass(clazz)
.load();

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////
// bit-inspector: Tool detecting bit rots in files.
// bit-backup: Tool detecting bit rots in files.
// Copyright (C) 2023-2023 the original author or authors.
//
// This program is free software; you can redistribute it and/or
@ -16,7 +16,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
///////////////////////////////////////////////////////////////////////////////////////////////
package org.nanoboot.bitinspector.persistence.impl.sqlite;
package org.nanoboot.bitbackup.persistence.impl.sqlite;
import java.sql.Connection;
import java.sql.PreparedStatement;
@ -25,12 +25,12 @@ import java.sql.SQLException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.nanoboot.bitinspector.entity.SystemItem;
import org.nanoboot.bitinspector.persistence.api.SystemItemRepository;
import org.nanoboot.bitbackup.entity.SystemItem;
import org.nanoboot.bitbackup.persistence.api.SystemItemRepository;
/**
*
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
* @author <a href="mailto:mail@robertvokac.com">Robert Vokac</a>
*/
public class SystemItemRepositoryImplSqlite implements SystemItemRepository {
@ -130,7 +130,30 @@ public class SystemItemRepositoryImplSqlite implements SystemItemRepository {
@Override
public void remove(String key) {
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
if (key == null) {
throw new RuntimeException("key is null");
}
StringBuilder sb = new StringBuilder();
sb
.append("DELETE FROM ")
.append(SystemItemTable.TABLE_NAME)
.append(" WHERE ")
.append(SystemItemTable.KEY)
.append("=?");
String sql = sb.toString();
try (
Connection connection = sqliteConnectionFactory.createConnection(); PreparedStatement stmt = connection.prepareStatement(sql);) {
stmt.executeQuery();
} catch (SQLException e) {
System.out.println(e.getMessage());
throw new RuntimeException(e);
} catch (ClassNotFoundException ex) {
Logger.getLogger(SystemItemRepositoryImplSqlite.class.getName()).log(Level.SEVERE, null, ex);
} finally {
}
}
@Override

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////
// bit-inspector: Tool detecting bit rots in files.
// bit-backup: Tool detecting bit rots in files.
// Copyright (C) 2023-2023 the original author or authors.
//
// This program is free software; you can redistribute it and/or
@ -16,7 +16,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
///////////////////////////////////////////////////////////////////////////////////////////////
package org.nanoboot.bitinspector.persistence.impl.sqlite;
package org.nanoboot.bitbackup.persistence.impl.sqlite;
import lombok.AllArgsConstructor;
import lombok.Getter;
@ -24,7 +24,7 @@ import lombok.Setter;
/**
*
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
* @author <a href="mailto:mail@robertvokac.com">Robert Vokac</a>
*/
@Getter
@Setter