-
Notifications
You must be signed in to change notification settings - Fork 50
/
localhandler.go
38 lines (32 loc) · 931 Bytes
/
localhandler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package infrastructure
import (
"interfaces"
"usecases"
. "utils"
"fmt"
"os"
)
type LocalHandler struct {}
var LocalInteractor *usecases.LocalInteractor
func NewLocalHandler() *LocalHandler {
gcpHandler := new(LocalHandler)
return gcpHandler
}
func (handler *LocalHandler) FileExists(fileName string) (fileExists bool, err error) {
_, err = os.Stat(fmt.Sprintf("%s/%s", Config.DownloadDir, fileName))
if !os.IsNotExist(err) {
fileExists = true
}
return
}
func GetLocalInteractor() (localInteractor *usecases.LocalInteractor, err error) {
if LocalInteractor == nil {
localHandler := NewLocalHandler()
localHandlers := make(map[string] interfaces.LocalHandler)
localHandlers["LocalFileSystemRepo"] = localHandler
localInteractor = new(usecases.LocalInteractor)
localInteractor.LocalRepository = interfaces.NewLocalRepo(localHandlers)
LocalInteractor = localInteractor
}
return LocalInteractor, nil
}