mirror of
https://github.com/usatiuk/backup.git
synced 2025-10-26 17:37:47 +01:00
repofs kinda working
This commit is contained in:
@@ -3,13 +3,13 @@ cmake_minimum_required(VERSION 3.22)
|
|||||||
#add_compile_options(-Ofast)
|
#add_compile_options(-Ofast)
|
||||||
#add_link_options(-Ofast)
|
#add_link_options(-Ofast)
|
||||||
|
|
||||||
# add_compile_options(-Ofast -flto)
|
add_compile_options(-Ofast -flto)
|
||||||
# add_link_options(-Ofast -flto)
|
add_link_options(-Ofast -flto)
|
||||||
|
|
||||||
add_compile_options(-Wall -O0 -Wextra -pedantic -Wshadow -Wformat=2 -Wfloat-equal -D_GLIBCXX_DEBUG -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -g -rdynamic)
|
#add_compile_options(-Wall -O0 -Wextra -pedantic -Wshadow -Wformat=2 -Wfloat-equal -D_GLIBCXX_DEBUG -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -g -rdynamic)
|
||||||
add_compile_options(-fsanitize=address -fsanitize=undefined -fno-sanitize-recover)
|
#add_compile_options(-fsanitize=address -fsanitize=undefined -fno-sanitize-recover)
|
||||||
add_link_options(-fsanitize=address -fsanitize=undefined -fno-sanitize-recover)
|
#add_link_options(-fsanitize=address -fsanitize=undefined -fno-sanitize-recover)
|
||||||
add_link_options(-rdynamic)
|
#add_link_options(-rdynamic)
|
||||||
|
|
||||||
project(backup)
|
project(backup)
|
||||||
|
|
||||||
|
|||||||
@@ -9,5 +9,5 @@ CommandMount::CommandMount() : Command("mount") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CommandMount::run(Context ctx) {
|
void CommandMount::run(Context ctx) {
|
||||||
RepoFS::start(ctx.repo, "./hi");
|
RepoFS::start(ctx.repo, ctx.repo->getConfig().getStr("to"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ static int rfsGetattr(const char *path, struct stat *stbuf) {
|
|||||||
e = getf(path);
|
e = getf(path);
|
||||||
if (e->isFakeDir || e->file->fileType == File::Type::Directory) {
|
if (e->isFakeDir || e->file->fileType == File::Type::Directory) {
|
||||||
stbuf->st_mode = S_IFDIR | 0755;
|
stbuf->st_mode = S_IFDIR | 0755;
|
||||||
stbuf->st_nlink = 1;
|
stbuf->st_nlink = 2;
|
||||||
} else if (e->file->fileType == File::Type::Normal) {
|
} else if (e->file->fileType == File::Type::Normal) {
|
||||||
stbuf->st_mode = S_IFREG | 0444;
|
stbuf->st_mode = S_IFREG | 0444;
|
||||||
stbuf->st_nlink = 1;
|
stbuf->st_nlink = 1;
|
||||||
@@ -137,9 +137,9 @@ void RepoFS::start(Repository *repo, std::string path) {
|
|||||||
for (auto const &f: a.files) {
|
for (auto const &f: a.files) {
|
||||||
auto file = Serialize::deserialize<File>(repo->getObject(f));
|
auto file = Serialize::deserialize<File>(repo->getObject(f));
|
||||||
auto path = std::filesystem::u8path(file.name);
|
auto path = std::filesystem::u8path(file.name);
|
||||||
DirEntry *entry = &(root.children[r.first]);
|
DirEntry *entry = &(root.children[std::to_string(a.id)]);
|
||||||
entry->isFakeDir = true;
|
entry->isFakeDir = true;
|
||||||
entry->name = a.name;
|
entry->name = std::to_string(a.id);
|
||||||
for (auto const &subp: path) {
|
for (auto const &subp: path) {
|
||||||
entry = &entry->children[subp];
|
entry = &entry->children[subp];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,6 +120,9 @@ AIDS=()
|
|||||||
OUT=$($CMD list --repo testdir/to1 --password asdff)
|
OUT=$($CMD list --repo testdir/to1 --password asdff)
|
||||||
echo "$OUT"
|
echo "$OUT"
|
||||||
|
|
||||||
|
mkdir testmount
|
||||||
|
$CMD mount --repo testdir/to1 --password asdff --to testmount &
|
||||||
|
|
||||||
while IFS= read -r l; do
|
while IFS= read -r l; do
|
||||||
((i++))
|
((i++))
|
||||||
aid=$(echo $l | grep -Eo '[0-9]+' | tail -1)
|
aid=$(echo $l | grep -Eo '[0-9]+' | tail -1)
|
||||||
@@ -129,9 +132,16 @@ while IFS= read -r l; do
|
|||||||
echo "Archive not restored properly!"
|
echo "Archive not restored properly!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
if ! diff --no-dereference -r testmount/$((aid)) testdir/res$((i)); then
|
||||||
|
echo "Archive not mounted properly!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Restore $((i)) OK"
|
echo "Restore $((i)) OK"
|
||||||
done <<< "$OUT"
|
done <<< "$OUT"
|
||||||
|
|
||||||
|
umount testmount
|
||||||
|
|
||||||
OUT=$($CMD diff --from testdata/4 --repo testdir/to1 --password asdff --progress none --verbose 1 --aid ${AIDS[0]} --aid2 ${AIDS[1]})
|
OUT=$($CMD diff --from testdata/4 --repo testdir/to1 --password asdff --progress none --verbose 1 --aid ${AIDS[0]} --aid2 ${AIDS[1]})
|
||||||
echo "$OUT"
|
echo "$OUT"
|
||||||
if ! ( ( echo "$OUT" | grep -q 'c is different' ) && ! ( echo "$OUT" | grep -q 'a is different' ) && ! ( echo "$OUT" | grep -q 'l is different' )\
|
if ! ( ( echo "$OUT" | grep -q 'c is different' ) && ! ( echo "$OUT" | grep -q 'a is different' ) && ! ( echo "$OUT" | grep -q 'l is different' )\
|
||||||
@@ -290,5 +300,6 @@ echo "Backup 11 ok"
|
|||||||
|
|
||||||
rm -rf testdata
|
rm -rf testdata
|
||||||
rm -rf testdir
|
rm -rf testdir
|
||||||
|
rm -rf testmount
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
Reference in New Issue
Block a user