code refactoring, enabled memory db persist to fs.

This commit is contained in:
2023-05-25 11:13:46 +02:00
parent acfc5aa064
commit fd0b40ac46
10 changed files with 82 additions and 17 deletions

View File

@@ -21,6 +21,13 @@ type DirectoryEntry struct {
SHASum string `json:"shaSum"`
}
func isValidEntry(d fs.DirEntry) bool {
return !d.IsDir() &&
!strings.HasPrefix(d.Name(), ".") &&
!strings.HasSuffix(d.Name(), ".part") &&
!strings.HasSuffix(d.Name(), ".ytdl")
}
func walkDir(root string) (*[]DirectoryEntry, error) {
files := []DirectoryEntry{}
@@ -28,7 +35,7 @@ func walkDir(root string) (*[]DirectoryEntry, error) {
if err != nil {
return err
}
if !d.IsDir() && !strings.HasPrefix(d.Name(), ".") {
if isValidEntry(d) {
h := sha256.New()
h.Write([]byte(path))