1
0
Fork 0

Setup upload dir watcher at the last step.

This commit is contained in:
Alexander Andreev 2023-08-06 01:34:55 +04:00
parent 271c27f4ad
commit 3b15052330
Signed by: Arav
GPG Key ID: D22A817D95815393
1 changed files with 13 additions and 13 deletions

View File

@ -38,19 +38,6 @@ func main() {
return
}
watcha, err := watcher.NewInotifyWatcher()
if err != nil {
log.Fatalln(err)
}
defer watcha.Close()
if err := watcha.AddWatch(*uploadDir, watcher.CrDelMask); err != nil {
log.Fatalln(err)
}
uploadDirNotify := make(chan uint32)
go watcha.WatchForMask(uploadDirNotify, watcher.CrDelMask)
hashSalt, err := os.ReadFile(path.Join(os.Getenv("CREDENTIALS_DIRECTORY"), "salt"))
if err != nil {
log.Fatalln("failed to read hash salt file:", err)
@ -104,6 +91,19 @@ func main() {
doneSignal := make(chan os.Signal, 1)
signal.Notify(doneSignal, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
watcha, err := watcher.NewInotifyWatcher()
if err != nil {
log.Fatalln(err)
}
defer watcha.Close()
if err := watcha.AddWatch(*uploadDir, watcher.CrDelMask); err != nil {
log.Fatalln(err)
}
uploadDirNotify := make(chan uint32)
go watcha.WatchForMask(uploadDirNotify, watcher.CrDelMask)
go func() {
for {
select {