mirror of
https://github.com/fumiama/imago.git
synced 2026-06-23 11:40:24 +08:00
✨ add funcs in storage instance
This commit is contained in:
@@ -17,6 +17,8 @@ type StorageInstance interface {
|
|||||||
IsImgExsits(name string) bool
|
IsImgExsits(name string) bool
|
||||||
AddImage(name string)
|
AddImage(name string)
|
||||||
Pick(exclude []string) string
|
Pick(exclude []string) string
|
||||||
|
SaveConf(data []byte) error
|
||||||
|
GetConf() ([]byte, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type storage struct {
|
type storage struct {
|
||||||
|
|||||||
@@ -120,3 +120,13 @@ func (ns *NativeStorage) ScanImgs(imgdir string) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SaveConf Save config file into storage
|
||||||
|
func (ns *NativeStorage) SaveConf(data []byte) error {
|
||||||
|
return os.WriteFile("conf.pb", data, 0644)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveConf Save config file into storage
|
||||||
|
func (ns *NativeStorage) GetConf() ([]byte, error) {
|
||||||
|
return os.ReadFile("conf.pb")
|
||||||
|
}
|
||||||
|
|||||||
@@ -123,3 +123,14 @@ func (remo *RemoteStorage) ScanImgs(imgdir string) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SaveConf Save config file into storage
|
||||||
|
func (remo *RemoteStorage) SaveConf(data []byte) error {
|
||||||
|
return remo.cli.SetFile("cfg", "conf.pb", data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveConf Save config file into storage
|
||||||
|
func (remo *RemoteStorage) GetConf() (data []byte, err error) {
|
||||||
|
data, _, err = remo.cli.GetFile("cfg", "conf.pb")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user