Skipped folders with errors
This commit is contained in:
parent
774bbbd97a
commit
876de16c58
|
@ -39,6 +39,9 @@ func (r *sqlRepository) updateTags(itemID string, tags model.Tags) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if len(tags) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
sqi := Insert("item_tags").Columns("item_id", "item_type", "tag_name", "tag_id").
|
sqi := Insert("item_tags").Columns("item_id", "item_type", "tag_name", "tag_id").
|
||||||
Suffix("on conflict (item_id, item_type, tag_id) do nothing")
|
Suffix("on conflict (item_id, item_type, tag_id) do nothing")
|
||||||
for name, values := range tags {
|
for name, values := range tags {
|
||||||
|
|
|
@ -451,7 +451,7 @@ func isExcludedTag(tagName string) bool {
|
||||||
|
|
||||||
func (t Tags) ModelTags() model.Tags {
|
func (t Tags) ModelTags() model.Tags {
|
||||||
models := model.Tags{}
|
models := model.Tags{}
|
||||||
for tagName, values := range t.tags {
|
for tagName, values := range t.Tags {
|
||||||
if isExcludedTag(tagName) {
|
if isExcludedTag(tagName) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,8 @@ func walkDirTree(ctx context.Context, scanCtx *scanContext) (<-chan *folderEntry
|
||||||
func walkFolder(ctx context.Context, scanCtx *scanContext, currentFolder string, results chan<- *folderEntry) error {
|
func walkFolder(ctx context.Context, scanCtx *scanContext, currentFolder string, results chan<- *folderEntry) error {
|
||||||
folder, children, err := loadDir(ctx, scanCtx, currentFolder)
|
folder, children, err := loadDir(ctx, scanCtx, currentFolder)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
log.Warn(ctx, "Scanner: Error loading dir. Skipping", "path", currentFolder, err)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
scanCtx.numFolders.Add(1)
|
scanCtx.numFolders.Add(1)
|
||||||
for _, c := range children {
|
for _, c := range children {
|
||||||
|
@ -97,23 +98,26 @@ func loadDir(ctx context.Context, scanCtx *scanContext, dirPath string) (folder
|
||||||
|
|
||||||
dirInfo, err := os.Stat(dirPath)
|
dirInfo, err := os.Stat(dirPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(ctx, "Scanner: Error stating dir", "path", dirPath, err)
|
log.Warn(ctx, "Scanner: Error stating dir", "path", dirPath, err)
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
folder.modTime = dirInfo.ModTime()
|
folder.modTime = dirInfo.ModTime()
|
||||||
|
|
||||||
dir, err := os.Open(dirPath)
|
dir, err := os.Open(dirPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(ctx, "Scanner: Error in Opening directory", "path", dirPath, err)
|
log.Warn(ctx, "Scanner: Error in Opening directory", "path", dirPath, err)
|
||||||
return folder, children, err
|
return folder, children, err
|
||||||
}
|
}
|
||||||
defer dir.Close()
|
defer dir.Close()
|
||||||
|
|
||||||
for _, entry := range fullReadDir(ctx, dir) {
|
for _, entry := range fullReadDir(ctx, dir) {
|
||||||
|
if ctx.Err() != nil {
|
||||||
|
return folder, children, ctx.Err()
|
||||||
|
}
|
||||||
isDir, err := isDirOrSymlinkToDir(dirPath, entry)
|
isDir, err := isDirOrSymlinkToDir(dirPath, entry)
|
||||||
// Skip invalid symlinks
|
// Skip invalid symlinks
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(ctx, "Scanner: Invalid symlink", "dir", filepath.Join(dirPath, entry.Name()), err)
|
log.Warn(ctx, "Scanner: Invalid symlink", "dir", filepath.Join(dirPath, entry.Name()), err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if isDir && !isDirIgnored(dirPath, entry) && isDirReadable(ctx, dirPath, entry) {
|
if isDir && !isDirIgnored(dirPath, entry) && isDirReadable(ctx, dirPath, entry) {
|
||||||
|
@ -121,7 +125,7 @@ func loadDir(ctx context.Context, scanCtx *scanContext, dirPath string) (folder
|
||||||
} else {
|
} else {
|
||||||
fileInfo, err := entry.Info()
|
fileInfo, err := entry.Info()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(ctx, "Scanner: Error getting fileInfo", "name", entry.Name(), err)
|
log.Warn(ctx, "Scanner: Error getting fileInfo", "name", entry.Name(), err)
|
||||||
return folder, children, err
|
return folder, children, err
|
||||||
}
|
}
|
||||||
if fileInfo.ModTime().After(folder.modTime) {
|
if fileInfo.ModTime().After(folder.modTime) {
|
||||||
|
@ -151,6 +155,9 @@ func fullReadDir(ctx context.Context, dir fs.ReadDirFile) []fs.DirEntry {
|
||||||
var allEntries []fs.DirEntry
|
var allEntries []fs.DirEntry
|
||||||
var prevErrStr = ""
|
var prevErrStr = ""
|
||||||
for {
|
for {
|
||||||
|
if ctx.Err() != nil {
|
||||||
|
return []fs.DirEntry{}
|
||||||
|
}
|
||||||
entries, err := dir.ReadDir(-1)
|
entries, err := dir.ReadDir(-1)
|
||||||
allEntries = append(allEntries, entries...)
|
allEntries = append(allEntries, entries...)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
Loading…
Reference in New Issue