Move directories

This commit is contained in:
EnumDev 2025-05-03 10:47:32 +03:00
parent eb8db1bc99
commit 4a8c4e22ec
3 changed files with 11 additions and 5 deletions

View File

@ -60,7 +60,13 @@ func CompileSourcePackage(archiveFilename, outputDirectory string, skipChecks bo
gid = os.Getgid()
}
tempDirectory := path.Join(homeDir, ".cache/bpm/compilation/", bpmpkg.PkgInfo.Name)
// Set temporary directory
var tempDirectory string
if os.Getuid() == 0 {
tempDirectory = path.Join("/var/cache/bpm/compilation/", bpmpkg.PkgInfo.Name)
} else {
tempDirectory = path.Join(homeDir, ".cache/bpm/compilation/", bpmpkg.PkgInfo.Name)
}
// Ensure temporary directory does not exist
if _, err := os.Stat(tempDirectory); err == nil {

View File

@ -516,7 +516,7 @@ func (operation *BPMOperation) Execute(verbose, force bool) (err error) {
// Compile package if type is 'source'
if bpmpkg.PkgInfo.Type == "source" {
// Get path to compiled package directory
compiledDir := path.Join(operation.RootDir, "/var/lib/bpm/compiled/")
compiledDir := path.Join(operation.RootDir, "/var/cache/bpm/compiled/")
// Create compiled package directory if not exists
if _, err := os.Stat(compiledDir); err != nil {

View File

@ -266,16 +266,16 @@ func (repo *Repository) FetchPackage(pkg string) (string, error) {
}
defer resp.Body.Close()
err = os.MkdirAll("/var/cache/bpm/packages/", 0755)
err = os.MkdirAll("/var/cache/bpm/fetched/", 0755)
if err != nil {
return "", err
}
out, err := os.Create("/var/cache/bpm/packages/" + path.Base(entry.Download))
out, err := os.Create("/var/cache/bpm/fetched/" + path.Base(entry.Download))
if err != nil {
return "", err
}
defer out.Close()
_, err = io.Copy(out, resp.Body)
return "/var/cache/bpm/packages/" + path.Base(entry.Download), nil
return "/var/cache/bpm/fetched/" + path.Base(entry.Download), nil
}