forked from vieter-v/vieter
Compare commits
No commits in common. "871ce8a407f4ea1acd009a448c33d6bce9379734" and "022f8c4fbe0da6b1f0c1b2a7b6c913e7ce71c25d" have entirely different histories.
871ce8a407
...
022f8c4fbe
|
|
@ -74,9 +74,6 @@ fn (r &Repo) add(pkg &package.Pkg) ?bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// We remove the older package version first, if present
|
|
||||||
r.remove(pkg.info.name, false) ?
|
|
||||||
|
|
||||||
os.mkdir(pkg_dir) or { return error('Failed to create package directory.') }
|
os.mkdir(pkg_dir) or { return error('Failed to create package directory.') }
|
||||||
|
|
||||||
os.write_file(os.join_path_single(pkg_dir, 'desc'), pkg.to_desc()) or {
|
os.write_file(os.join_path_single(pkg_dir, 'desc'), pkg.to_desc()) or {
|
||||||
|
|
@ -95,31 +92,6 @@ fn (r &Repo) add(pkg &package.Pkg) ?bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove removes a package from the database. It returns false if the package
|
|
||||||
// wasn't present in the database.
|
|
||||||
fn (r &Repo) remove(pkg_name string, sync bool) ?bool {
|
|
||||||
// We iterate over every directory in the repo dir
|
|
||||||
for d in os.ls(r.repo_dir) ? {
|
|
||||||
name := d.split('-')#[..-2].join('-')
|
|
||||||
|
|
||||||
if name == pkg_name {
|
|
||||||
// We lock the mutex here to prevent other routines from creating a
|
|
||||||
// new archive while we removed an entry
|
|
||||||
lock r.mutex {
|
|
||||||
os.rmdir_all(os.join_path_single(r.repo_dir, d)) ?
|
|
||||||
}
|
|
||||||
|
|
||||||
if sync {
|
|
||||||
r.sync() ?
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns the path where the given package's desc & files files are stored
|
// Returns the path where the given package's desc & files files are stored
|
||||||
fn (r &Repo) pkg_path(pkg &package.Pkg) string {
|
fn (r &Repo) pkg_path(pkg &package.Pkg) string {
|
||||||
return os.join_path(r.repo_dir, '$pkg.info.name-$pkg.info.version')
|
return os.join_path(r.repo_dir, '$pkg.info.name-$pkg.info.version')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue