Can upload new gong
This commit is contained in:
parent
f0967f3b9d
commit
cc301da971
4 changed files with 121 additions and 4 deletions
|
|
@ -23,6 +23,23 @@ func CurrentGongPath(cfg *config.Config) string {
|
|||
return filepath.Join(cfg.GongsDir, CURRENT_GONG)
|
||||
}
|
||||
|
||||
func LoadGong(cfg *config.Config, path string, d fs.FileInfo) (gong *Gong, err error) {
|
||||
// Retrieve the path of the current gong
|
||||
current_gong, err := os.Readlink(CurrentGongPath(cfg))
|
||||
if err == nil {
|
||||
current_gong, _ = filepath.Abs(filepath.Join(cfg.GongsDir, current_gong))
|
||||
}
|
||||
|
||||
hash := sha512.Sum512([]byte(path))
|
||||
pabs, _ := filepath.Abs(path)
|
||||
return &Gong{
|
||||
Id: hash[:],
|
||||
Name: strings.TrimSuffix(d.Name(), filepath.Ext(d.Name())),
|
||||
Path: path,
|
||||
Enabled: current_gong == pabs,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func LoadGongs(cfg *config.Config) (gongs []*Gong, err error) {
|
||||
// Retrieve the path of the current gong
|
||||
current_gong, err := os.Readlink(CurrentGongPath(cfg))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue