Skip to content

Commit

Permalink
Merge pull request #25 from lomorage/doc
Browse files Browse the repository at this point in the history
add flatten root scan directory into iso file
  • Loading branch information
dwebfan authored Jul 9, 2024
2 parents 5e07fcb + 1407991 commit 95c80d3
Show file tree
Hide file tree
Showing 10 changed files with 390 additions and 206 deletions.
2 changes: 1 addition & 1 deletion cmd/lomob/iso.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func createIso(maxSize uint64, isoFilename string, scanRootDirs map[int]string,
continue
}
srcFile := filepath.Join(scanRootDir, f.Name)
dstFile := filepath.Join(stagingDir, f.Name)
dstFile := filepath.Join(filepath.Join(stagingDir, flattenScanRootDir(scanRootDir)), f.Name)

// create dir
dstDir := filepath.Dir(dstFile)
Expand Down
3 changes: 3 additions & 0 deletions test/scripts/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ rm -f lomob.db; sqlite3 ./lomob.db < ../../common/dbx/schema/1.sql

# test upload encrypt file
#./test-upload-aws-encrypt.sh

# test scan 2 different root dirs
./test-2-root-dirs.sh
279 changes: 140 additions & 139 deletions test/scripts/files_2019-04-03--2024-04-17.txt

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions test/scripts/files_2021-04-26--2021-04-26.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/
└── [ 04/17/2024] static
└── [ 03/03/2023] img
└── [ 05/03/2021] buy
├── [ 2494420 04/26/2021] local.png
├── [ 14578386 04/26/2021] lomorage-mini.png
└── [ 14885871 04/26/2021] lomorage-setup.png
└── [ 04/17/2024] _go_src_github.com_lomorage_lomo-backup_test_data
└── [ 04/17/2024] static
└── [ 03/03/2023] img
└── [ 05/03/2021] buy
├── [ 2494420 04/26/2021] local.png
├── [ 14578386 04/26/2021] lomorage-mini.png
└── [ 14885871 04/26/2021] lomorage-setup.png

43 changes: 22 additions & 21 deletions test/scripts/files_2021-04-26--2021-07-31.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
/
└── [ 04/17/2024] static
├── [ 03/03/2023] img
│ ├── [ 05/03/2021] buy
│ │ ├── [ 304081 05/03/2021] search-en.png
│ │ ├── [ 476712 04/26/2021] search.png
│ │ ├── [ 351826 05/03/2021] settings-en.png
│ │ ├── [ 382947 04/26/2021] settings.png
│ │ ├── [ 1595170 05/03/2021] web-gallery-en.png
│ │ ├── [ 1207368 04/26/2021] web-gallery.png
│ │ ├── [ 669073 05/03/2021] web-upload-en.png
│ │ └── [ 1044760 04/26/2021] web-upload.png
│ └── [ 07/31/2021] links
│ ├── [ 72809 07/06/2021] appinn.png
│ ├── [ 47005 07/06/2021] canalapps.png
│ ├── [ 32607 07/06/2021] futurezone.png
│ ├── [ 189043 07/06/2021] iplaysoft.png
│ ├── [ 23906 07/06/2021] medium.png
│ └── [ 8714 07/31/2021] x1g.png
└── [ 06/15/2021] video
├── [ 13940681 06/15/2021] Lomorage-tutorial.mp4
└── [ 21164705 06/15/2021] Lomorage-tutorial.zh.mp4
└── [ 04/17/2024] _go_src_github.com_lomorage_lomo-backup_test_data
└── [ 04/17/2024] static
├── [ 03/03/2023] img
│ ├── [ 05/03/2021] buy
│ │ ├── [ 304081 05/03/2021] search-en.png
│ │ ├── [ 476712 04/26/2021] search.png
│ │ ├── [ 351826 05/03/2021] settings-en.png
│ │ ├── [ 382947 04/26/2021] settings.png
│ │ ├── [ 1595170 05/03/2021] web-gallery-en.png
│ │ ├── [ 1207368 04/26/2021] web-gallery.png
│ │ ├── [ 669073 05/03/2021] web-upload-en.png
│ │ └── [ 1044760 04/26/2021] web-upload.png
│ └── [ 07/31/2021] links
│ ├── [ 72809 07/06/2021] appinn.png
│ ├── [ 47005 07/06/2021] canalapps.png
│ ├── [ 32607 07/06/2021] futurezone.png
│ ├── [ 189043 07/06/2021] iplaysoft.png
│ ├── [ 23906 07/06/2021] medium.png
│ └── [ 8714 07/31/2021] x1g.png
└── [ 06/15/2021] video
├── [ 13940681 06/15/2021] Lomorage-tutorial.mp4
└── [ 21164705 06/15/2021] Lomorage-tutorial.zh.mp4

118 changes: 118 additions & 0 deletions test/scripts/files_2_dirs_2019-04-03--2024-04-17.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/
├── [ 03/17/2024] _go_src_github.com_lomorage_lomo-backup_test_data_content
│ ├── [ 3445 03/23/2022] _index.md
│ ├── [ 3163 05/03/2022] _index.zh.md
│ ├── [ 03/17/2024] blog
│ │ ├── [ 9089 08/24/2020] covid19.md
│ │ ├── [ 8308 06/12/2020] covid19.zh.md
│ │ ├── [ 2664 05/12/2020] ddns.md.bak
│ │ ├── [ 8252 10/14/2022] flyio.md
│ │ ├── [ 5853 08/22/2020] import_my_cloud.md
│ │ ├── [ 6206 05/18/2020] import_my_cloud.zh.md
│ │ ├── [ 3074 03/03/2023] migrate_from_pi_win.zh.md
│ │ ├── [ 2002 03/02/2023] mypains.zh.md
│ │ ├── [ 6747 03/17/2024] photoprism.md
│ │ ├── [ 6733 10/31/2022] photoprism.zh.md
│ │ ├── [ 4808 09/04/2021] piq-size.md
│ │ ├── [ 5072 11/06/2023] raspberrypi-hd.md
│ │ ├── [ 4715 11/06/2023] raspberrypi-hd.zh.md
│ │ ├── [ 5550 03/02/2023] set_wd_as_backup.md
│ │ ├── [ 1708 03/02/2023] set_wd_as_backup.zh.md
│ │ ├── [ 4130 08/22/2020] transfer2pc.zh.md
│ │ ├── [ 2227 11/17/2020] windows-docker.md
│ │ ├── [ 1899 11/17/2020] windows-docker.zh.md
│ │ ├── [ 1529 08/26/2021] zero-cost-android-frame.md
│ │ └── [ 1936 08/26/2021] zero-cost-android-frame.zh.md
│ ├── [ 7111 03/08/2021] compare.md
│ ├── [ 7571 03/08/2021] compare.zh.md
│ ├── [ 236 11/06/2023] contact.md
│ ├── [ 193 11/06/2023] contact.zh.md
│ ├── [ 7946 06/06/2022] faq.md
│ ├── [ 7612 06/06/2022] faq.zh.md
│ ├── [ 250 04/02/2021] survey.md
│ └── [ 263 03/21/2022] survey.zh.md
└── [ 04/17/2024] _go_src_github.com_lomorage_lomo-backup_test_data_static
├── [ 13 04/12/2019] CNAME
├── [ 59 04/17/2024] ads.txt
├── [ 59 03/17/2024] app-ads.txt
├── [ 03/03/2023] img
│ ├── [ 6340 04/03/2019] apple-touch-icon.png
│ ├── [ 03/03/2023] blog
│ │ ├── [ 08/26/2021] android-frame
│ │ │ ├── [ 620731 08/26/2021] android-frame-banner.png
│ │ │ ├── [ 66740 08/26/2021] lomorage_wechat_qr.jpg
│ │ │ └── [ 20867047 08/26/2021] phone-share.gif
│ │ ├── [ 03/30/2020] covid19
│ │ │ ├── [ 112106 03/30/2020] covid19.jpg
│ │ │ ├── [ 207059 03/30/2020] dashboard-en.png
│ │ │ ├── [ 284169 03/30/2020] dashboard-zh.png
│ │ │ └── [ 6648 03/30/2020] layout.png
│ │ ├── [ 10/14/2022] flyio
│ │ │ └── [ 9781 10/14/2022] logo.svg
│ │ ├── [ 09/02/2021] image-quality
│ │ │ ├── [ 105323 09/02/2021] 320_perc.png
│ │ │ ├── [ 106330 09/02/2021] 320_size.png
│ │ │ ├── [ 79878 09/02/2021] 640_perc.png
│ │ │ └── [ 101593 09/02/2021] 640_size.png
│ │ ├── [ 05/18/2020] import_my_cloud
│ │ │ ├── [ 25562 05/18/2020] 6822a363-9172-4e35-b77c-5318ea01c50a.png
│ │ │ ├── [ 20850 05/18/2020] ad38c19b-10b1-4b82-92ec-68b6f2481601-1.png
│ │ │ ├── [ 36065 05/18/2020] banner_mycloud_lomo.png
│ │ │ ├── [ 66213 05/18/2020] f14b9c18-f941-429a-a848-1426f547ab37.png
│ │ │ └── [ 9906 05/18/2020] f6a46087-7e46-47c6-8568-e551d062bd6e.png
│ │ ├── [ 77900 03/02/2023] lomorage_wechat_qr.jpg
│ │ ├── [ 03/03/2023] migrate_from_pi_win
│ │ │ ├── [ 52945 03/03/2023] assets_db_zh.png
│ │ │ ├── [ 21265 03/03/2023] migrate_pi_win.jpg
│ │ │ └── [ 13632 03/03/2023] one_click_recover.png
│ │ ├── [ 07/20/2020] mypains
│ │ │ ├── [ 78378 07/20/2020] banner.pdn
│ │ │ └── [ 50489 07/20/2020] banner.png
│ │ ├── [ 02/12/2022] photoprism
│ │ │ └── [ 25647 02/12/2022] photoprism-banner.jpeg
│ │ ├── [ 06/15/2021] raspberrypi-hd
│ │ │ └── [ 238208 06/15/2021] power-hub-adafruit.jpg
│ │ ├── [ 03/02/2023] set_wd_as_backup
│ │ │ ├── [ 74188 02/23/2023] mount.png
│ │ │ ├── [ 60212 03/02/2023] mount_zh.png
│ │ │ ├── [ 34156 02/23/2023] set_redundancy_agent.png
│ │ │ ├── [ 37990 03/02/2023] set_redundancy_agent_zh.png
│ │ │ └── [ 17092 02/23/2023] set_wd_as_backup.jpg
│ │ ├── [ 03/31/2020] transfer_pc
│ │ │ ├── [ 59333 03/31/2020] 13c696c2-1c30-4906-be64-ed7ab3d115a7.png
│ │ │ ├── [ 118026 03/31/2020] 3d2ba39a-e52a-47a0-9074-39c9bb43f58c.jpg
│ │ │ ├── [ 51157 03/31/2020] 4db9e626-29d9-4586-963b-ff3e63cb93f9.png
│ │ │ ├── [ 50054 03/31/2020] 5f783099-ce8c-4535-839e-444704ce9300.png
│ │ │ ├── [ 128629 03/31/2020] a155dcc4-37c3-44bf-aea1-8ec5306e2b78.jpg
│ │ │ ├── [ 28646 03/31/2020] a8f7743d-2770-4537-9b44-f79a698d7243.png
│ │ │ ├── [ 44094 03/31/2020] ad256b83-38a9-4a7c-a983-ad5a3c34fc58.png
│ │ │ ├── [ 13926 03/31/2020] cbd625dc-783d-430b-a51b-6204a28e488d.png
│ │ │ ├── [ 26872 03/31/2020] d7600bbe-28ac-4cfe-89c8-adcb8145dbb7.png
│ │ │ └── [ 14442 03/31/2020] transfer-photos.jpg
│ │ └── [ 11/17/2020] win-docker
│ │ ├── [ 53012 11/17/2020] docker.png
│ │ ├── [ 26175 11/17/2020] web-client.png
│ │ └── [ 61209 11/17/2020] win-docker-banner.png
│ ├── [ 05/03/2021] buy
│ │ ├── [ 1132695 05/03/2021] backup-en.png
│ │ ├── [ 1431468 04/26/2021] backup.png
│ │ └── [ 1565661 05/03/2021] local-en.png
│ ├── [ 2667 06/15/2021] data-storage-svgrepo-com.svg
│ ├── [ 10205 06/15/2021] delivery-truck-free-svgrepo-com.svg
│ ├── [ 8333 06/15/2021] family-svgrepo-com.svg
│ ├── [ 7560 04/03/2019] favicon.ico
│ ├── [ 3688 06/15/2021] file-storage-svgrepo-com.svg
│ ├── [ 3880 06/15/2021] hard-disk-svgrepo-com.svg
│ ├── [ 20225 10/15/2021] logo.png
│ ├── [ 3984 06/15/2021] platform-svgrepo-com.svg
│ ├── [ 3540 06/15/2021] raw-svgrepo-com.svg
│ ├── [ 2806 06/15/2021] security-svgrepo-com.svg
│ └── [ 4678 06/15/2021] undraw-devices.svg
├── [ 525451 01/06/2020] lomorage.key
├── [ 60530 01/06/2020] lomorage.pdf
├── [ 497252 01/06/2020] lomorage.zh.key
├── [ 105524 01/06/2020] lomorage.zh.pdf
├── [ 165694 11/13/2023] privacy.html
├── [ 951 04/16/2024] release.json
└── [ 229986 11/15/2020] term.pdf

8 changes: 8 additions & 0 deletions test/scripts/files_2_dirs_2021-04-26--2021-04-26.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/
└── [ 04/17/2024] _go_src_github.com_lomorage_lomo-backup_test_data_static
└── [ 03/03/2023] img
└── [ 05/03/2021] buy
├── [ 2494420 04/26/2021] local.png
├── [ 14578386 04/26/2021] lomorage-mini.png
└── [ 14885871 04/26/2021] lomorage-setup.png

23 changes: 23 additions & 0 deletions test/scripts/files_2_dirs_2021-04-26--2021-07-31.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/
└── [ 04/17/2024] _go_src_github.com_lomorage_lomo-backup_test_data_static
├── [ 03/03/2023] img
│ ├── [ 05/03/2021] buy
│ │ ├── [ 304081 05/03/2021] search-en.png
│ │ ├── [ 476712 04/26/2021] search.png
│ │ ├── [ 351826 05/03/2021] settings-en.png
│ │ ├── [ 382947 04/26/2021] settings.png
│ │ ├── [ 1595170 05/03/2021] web-gallery-en.png
│ │ ├── [ 1207368 04/26/2021] web-gallery.png
│ │ ├── [ 669073 05/03/2021] web-upload-en.png
│ │ └── [ 1044760 04/26/2021] web-upload.png
│ └── [ 07/31/2021] links
│ ├── [ 72809 07/06/2021] appinn.png
│ ├── [ 47005 07/06/2021] canalapps.png
│ ├── [ 32607 07/06/2021] futurezone.png
│ ├── [ 189043 07/06/2021] iplaysoft.png
│ ├── [ 23906 07/06/2021] medium.png
│ └── [ 8714 07/31/2021] x1g.png
└── [ 06/15/2021] video
├── [ 13940681 06/15/2021] Lomorage-tutorial.mp4
└── [ 21164705 06/15/2021] Lomorage-tutorial.zh.mp4

53 changes: 53 additions & 0 deletions test/scripts/test-2-root-dirs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash

set -e

expectTotalDirs=22
expectTotalFiles=118

rm ./lomob.db *.iso
sqlite3 ./lomob.db < ../../common/dbx/schema/1.sql

echo "scan data/content"
lomob scan -t 1 ../data/content

echo "scan data/static"
lomob scan -t 1 ../data/static


data=`sqlite3 ./lomob.db "select count(*) from dirs"`
if [ "$data" = "$expectTotalDirs" ]; then
echo "Number of scanned dirs pass"
else
echo "Number of scanned dirs is $data while expect $expectTotalDirs, failed!"
exit 1
fi

data=`sqlite3 ./lomob.db "select count(*) from files"`
if [ "$data" = "$expectTotalFiles" ]; then
echo "Number of scanned files pass"
else
echo "Number of scanned file is $data while expect $expectTotalFiles, failed!"
exit 1
fi

echo "start generate iso includes 2 root directory"

lomob iso create -s 30M --debug

echo "start compare iso output"
for name in "2019-04-03--2024-04-17" "2021-04-26--2021-04-26" "2021-04-26--2021-07-31";
do
isoFile=${name}".iso"

lomob iso dump $isoFile > /tmp/tmp

diff /tmp/tmp files_2_dirs_${name}.txt

if [ $? -eq 0 ]; then
echo "Dump iso $isoFile are same as expected"
else
echo "Dump iso $isoFile are different"
exit 1
fi
done
54 changes: 15 additions & 39 deletions test/scripts/test-iso-list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,42 +36,18 @@ fi

echo "Test dump iso files"

isoFile="2019-04-03--2024-04-17.iso"

lomob iso dump $isoFile > /tmp/tmp

diff /tmp/tmp files_2019-04-03--2024-04-17.txt


if [ $? -eq 0 ]; then
echo "Dump iso $isoFile are same as expected"
else
echo "Dump iso $isoFile are different"
exit 1
fi

isoFile="2021-04-26--2021-04-26.iso"

lomob iso dump $isoFile > /tmp/tmp

diff /tmp/tmp files_2021-04-26--2021-04-26.txt

if [ $? -eq 0 ]; then
echo "Dump iso $isoFile are same as expected"
else
echo "Dump iso $isoFile are different"
exit 1
fi

isoFile="2021-04-26--2021-07-31.iso"

lomob iso dump $isoFile > /tmp/tmp

diff /tmp/tmp files_2021-04-26--2021-07-31.txt

if [ $? -eq 0 ]; then
echo "Dump iso $isoFile are same as expected"
else
echo "Dump iso $isoFile are different"
exit 1
fi
for name in "2019-04-03--2024-04-17" "2021-04-26--2021-04-26" "2021-04-26--2021-07-31";
do
isoFile=${name}".iso"

lomob iso dump $isoFile > /tmp/tmp

diff /tmp/tmp files_${name}.txt

if [ $? -eq 0 ]; then
echo "Dump iso $isoFile are same as expected"
else
echo "Dump iso $isoFile are different"
exit 1
fi
done

0 comments on commit 95c80d3

Please sign in to comment.