fixing bug with config generation, started fixing add command, next commit command
This commit is contained in:
@@ -68,28 +68,6 @@ func ExpandToIntArray(length int64, arry []byte, intArray *[]int64) error {
|
||||
// return fileName, nil
|
||||
// }
|
||||
|
||||
//InitiateDirectory checks all of the directories to make sure they exist
|
||||
func InitiateDirectory(directory string) {
|
||||
// For the keys-folder we need to check if the folder exists...
|
||||
checkDir, err := IsDirectory(directory)
|
||||
if err != nil {
|
||||
fmt.Println("Error checking for "+directory+" directory: %s\r\n", err)
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if checkDir == true {
|
||||
fmt.Println(directory + " already exists")
|
||||
} else {
|
||||
// Create the directory.
|
||||
fmt.Println("Creating " + directory)
|
||||
err = CreateDirectory(directory)
|
||||
if err != nil {
|
||||
fmt.Println("Error creating the folder %s\r\n", err)
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func ConvertFileForStorage(file *database.File, folder string) error {
|
||||
fileBytes, err := ioutil.ReadFile(file.Path)
|
||||
if err != nil {
|
||||
|
||||
@@ -46,6 +46,7 @@ func NewManager(rootDir string, version string, dbPath string, informer chan Ope
|
||||
informer,
|
||||
dirPaths,
|
||||
}
|
||||
|
||||
return &m, nil
|
||||
}
|
||||
|
||||
@@ -112,13 +113,13 @@ func CreatePaths(rootDir string) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to generate file paths.. %s", err)
|
||||
}
|
||||
InitiateDirectory(fullFilePaths.KeyFolder)
|
||||
InitiateDirectory(fullFilePaths.DownloadFolder)
|
||||
InitiateDirectory(fullFilePaths.SyncFolder)
|
||||
InitiateDirectory(fullFilePaths.ObjectFolder)
|
||||
InitiateDirectory(fullFilePaths.ThumbFolder)
|
||||
InitiateDirectory(fullFilePaths.LogFolder)
|
||||
InitiateDirectory(fullFilePaths.PluginFolder)
|
||||
CreateDirectory(fullFilePaths.KeyFolder)
|
||||
CreateDirectory(fullFilePaths.DownloadFolder)
|
||||
CreateDirectory(fullFilePaths.SyncFolder)
|
||||
CreateDirectory(fullFilePaths.ObjectFolder)
|
||||
CreateDirectory(fullFilePaths.ThumbFolder)
|
||||
CreateDirectory(fullFilePaths.LogFolder)
|
||||
CreateDirectory(fullFilePaths.PluginFolder)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -160,6 +161,7 @@ func (m *Manager) AddFileToRepo(relFilePath string) error {
|
||||
if hash, err = UniqueFileHash(relFilePath); err != nil {
|
||||
return err
|
||||
}
|
||||
m.Info().Msgf("Hash generated for file: %s hash: %s", relFilePath, hex.EncodeToString(hash))
|
||||
alreadyTracked := m.dB.CheckIfFileCurrentlyMonitored(relFilePath)
|
||||
if alreadyTracked {
|
||||
return fmt.Errorf("file already found in tracked files, not adding: %s", relFilePath)
|
||||
|
||||
Reference in New Issue
Block a user