Restored progress
This commit is contained in:
parent
f615cff76d
commit
5244f87411
19 changed files with 1061 additions and 0 deletions
63
internal/core/config.go
Normal file
63
internal/core/config.go
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os/user"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
|
||||
// Config will follow this model
|
||||
// server : string
|
||||
// port : int
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Load config file
|
||||
func LoadConfig() error {
|
||||
|
||||
// Get current user
|
||||
currentUser, err := user.Current()
|
||||
if err != nil {
|
||||
// panic("LoadConfig: Failed to retrieve curent user -> " + err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
// Set default values
|
||||
viper.SetDefault("server", "example.com")
|
||||
viper.SetDefault("port", 5660)
|
||||
|
||||
// Set config paths
|
||||
viper.SetConfigName("config")
|
||||
viper.SetConfigType("json")
|
||||
viper.AddConfigPath("/etc/cosync/")
|
||||
viper.AddConfigPath("/home/" + currentUser.Username + "/.config/cosync")
|
||||
|
||||
// Read from config files
|
||||
err = viper.ReadInConfig()
|
||||
if err != nil {
|
||||
panic("LoadConfig: Failed to read config file -> " + err.Error())
|
||||
// return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Generate config folder and files
|
||||
func MkConfig() error {
|
||||
return errors.New("not implemented")
|
||||
}
|
||||
|
||||
// Load sync list from sync file
|
||||
func LoadSyncList() error {
|
||||
return errors.New("not implemented")
|
||||
}
|
||||
|
||||
// returns all config variables
|
||||
// ! WARNING: Do not use this function without executing LoadConfig prior
|
||||
func GetConfig() map[string]any {
|
||||
return viper.AllSettings()
|
||||
}
|
||||
25
internal/core/models.go
Normal file
25
internal/core/models.go
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type File struct {
|
||||
ID string
|
||||
ParentDirectory string
|
||||
Metadata FileMetadata
|
||||
State SynchronizationState
|
||||
}
|
||||
|
||||
type FileMetadata struct {
|
||||
Name string
|
||||
Size int64
|
||||
ModifiedTime time.Time
|
||||
Hash string // For comparing file content
|
||||
}
|
||||
|
||||
type SynchronizationState struct {
|
||||
Status string // "pending", "in_progress", "completed", "error"
|
||||
Progress float64
|
||||
LastError error
|
||||
}
|
||||
8
internal/core/utils.go
Normal file
8
internal/core/utils.go
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
package core
|
||||
|
||||
|
||||
//! Not implemented
|
||||
func CompareFiles(file1 File, file2 File) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue