-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement global storage path configuration and update command …
…syntax - Implemented global configuration for default storage path if not defined: - Uses `/home/.dabadee/Storage` if launched in a sub-directory of a non-root user - Uses `/opt/.dabadee/Storage` if launched as root from any other path - Updated command syntax for `dedup` and `cp` commands to use `--storage` and `--workers` flags
- Loading branch information
1 parent
7578df5
commit e4aeadb
Showing
3 changed files
with
46 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package cmd | ||
|
||
import ( | ||
"os/user" | ||
"path/filepath" | ||
) | ||
|
||
// GetDefaultStoragePath determines the default storage path based on user | ||
// and execution context | ||
func GetDefaultStoragePath() string { | ||
currentUser, err := user.Current() | ||
if err != nil { | ||
return "/opt/.dabadee/Storage" | ||
} | ||
|
||
if currentUser.Uid == "0" { | ||
// Running as root | ||
return "/opt/dabadee/Storage" | ||
} | ||
|
||
// Running as non-root user | ||
return filepath.Join(currentUser.HomeDir, ".dabadee/Storage") | ||
} |