Add support for lost files

This commit is contained in:
Quentin 2021-04-23 22:39:43 +02:00
parent b477c898ce
commit c0c8368012
Signed by: quentin
GPG key ID: A98E9B769E4FF428
2 changed files with 10 additions and 5 deletions

View file

@ -5,14 +5,16 @@ Seafile Recovery.
Usage: Usage:
seafile_recovery [--storage=<sto>] head <repoid> seafile_recovery [--storage=<sto>] head <repoid>
seafile_recovery [--storage=<sto>] ls <repoid> <pathid> seafile_recovery [--storage=<sto>] ls <repoid> (--dir=<dirid> | --file=<fileid>)
seafile_recovery [--storage=<sto>] dump <repoid> <pathid> seafile_recovery [--storage=<sto>] cp <repoid> (--dir=<dirid> | --file=<fileid>)
seafile_recovery [--storage=<sto>] s3 <repoid> <pathid> <bucket> seafile_recovery [--storage=<sto>] s3 <repoid> (--dir=<dirid> | --file=<pathid>) <s3url>
seafile_recovery (-h | --help) seafile_recovery (-h | --help)
Options: Options:
-h --help Show this screen -h --help Show this screen
--storage=<sto> Set Seafile storage path [default: ./storage] --storage=<sto> Set Seafile storage path [default: ./storage]
--dir=<dirid> Seafile Directory ID, can be obtained from commits as RootID
--file=<fileid> Seafile File ID, can be obtained through ls
``` ```
## Dev notes ## Dev notes

5
fs.go
View file

@ -108,6 +108,7 @@ func (dn* DirNode) Parse() {
jdec := json.NewDecoder(zfile) jdec := json.NewDecoder(zfile)
err = jdec.Decode(&dn.Elem) err = jdec.Decode(&dn.Elem)
if err != nil { log.Fatal(err) } if err != nil { log.Fatal(err) }
} }
func (fn* FileNode) Parse() { func (fn* FileNode) Parse() {
@ -130,7 +131,9 @@ func (dn* DirNode) Children() ([]*DirNode, []*FileNode) {
files := make([]*FileNode, 0) files := make([]*FileNode, 0)
for _, el := range dn.Elem.Entries { for _, el := range dn.Elem.Entries {
if IsDir(el.Mode) { if el.Id == "0000000000000000000000000000000000000000" {
log.Println("[Lost] "+dn.AbsolutePath+el.Name)
} else if IsDir(el.Mode) {
folders = append(folders, NewDirNode(dn, el)) folders = append(folders, NewDirNode(dn, el))
} else if IsRegular(el.Mode) { } else if IsRegular(el.Mode) {
files = append(files, NewFileNode(dn, el)) files = append(files, NewFileNode(dn, el))