Make sure that photo directory for user exists

If user directory doesn't exist anymore report an error notification.
This commit is contained in:
viktorstrate
2020-04-16 11:23:34 +02:00
parent 6e420dff41
commit d5227a4ce3

View File

@@ -99,6 +99,17 @@ func ScanUser(database *sql.DB, userId int) error {
func scan(database *sql.DB, user *models.User) {
// Check if user directory exists on the file system
if _, err := os.Stat(user.RootPath); err != nil {
if os.IsNotExist(err) {
ScannerError("Photo directory for user '%s' does not exist '%s'\n", user.Username, user.RootPath)
} else {
ScannerError("Could not read photo directory for user '%s': %s\n", user.Username, user.RootPath)
}
return
}
notifyKey := utils.GenerateToken()
processKey := utils.GenerateToken()
notifyThrottle := utils.NewThrottle(500 * time.Millisecond)