Loading bin/is +4 −1 Original line number Diff line number Diff line Loading @@ -103,7 +103,9 @@ def c_clean(parser, args): ''' Clean a repository ''' raise NotImplementedError("Not yet implemented") repoman = load_repositories(args) for reponame in args.repository: repoman[reponame].clean() def c_copy(parser, args): ''' Loading Loading @@ -320,6 +322,7 @@ p_cat.set_defaults(func=c_cat) # clean command parser p_clean = subparsers.add_parser("clean", help=c_clean.__doc__.lower()) p_clean.add_argument("repository", nargs="+", help="repositories to clean") p_clean.set_defaults(func=c_clean) # copy command parser Loading installsystems/repository.py +30 −0 Original line number Diff line number Diff line Loading @@ -175,6 +175,36 @@ class Repository(object): arrow(os.path.basename(obj.path), 1) os.unlink(obj.path) def getallmd5(self): ''' Get list of all md5 in DB ''' res = self.db.ask("SELECT md5 FROM image UNION SELECT md5 FROM payload").fetchall() return [ md5[0] for md5 in res ] def clean(self): ''' Clean the repository's content ''' # Check if the repo is local if not istools.isfile(self.config.path): raise Exception("Repository must be local") allmd5 = set(self.getallmd5()) repofiles = set(os.listdir(self.config.path)) - set([self.config.dbname, self.config.lastname]) dirtyfiles = repofiles - allmd5 if len(dirtyfiles) > 0: if not confirm("Remove dirty files? (yes) "): raise Exception("Aborted!") for f in dirtyfiles: p = os.path.join(self.config.path, f) try: if os.path.isdir(p): os.rmdir(p) else: os.unlink(p) except: raise Exception("Removing %s failed" % p) def delete(self, name, version): ''' Delete an image from repository Loading Loading
bin/is +4 −1 Original line number Diff line number Diff line Loading @@ -103,7 +103,9 @@ def c_clean(parser, args): ''' Clean a repository ''' raise NotImplementedError("Not yet implemented") repoman = load_repositories(args) for reponame in args.repository: repoman[reponame].clean() def c_copy(parser, args): ''' Loading Loading @@ -320,6 +322,7 @@ p_cat.set_defaults(func=c_cat) # clean command parser p_clean = subparsers.add_parser("clean", help=c_clean.__doc__.lower()) p_clean.add_argument("repository", nargs="+", help="repositories to clean") p_clean.set_defaults(func=c_clean) # copy command parser Loading
installsystems/repository.py +30 −0 Original line number Diff line number Diff line Loading @@ -175,6 +175,36 @@ class Repository(object): arrow(os.path.basename(obj.path), 1) os.unlink(obj.path) def getallmd5(self): ''' Get list of all md5 in DB ''' res = self.db.ask("SELECT md5 FROM image UNION SELECT md5 FROM payload").fetchall() return [ md5[0] for md5 in res ] def clean(self): ''' Clean the repository's content ''' # Check if the repo is local if not istools.isfile(self.config.path): raise Exception("Repository must be local") allmd5 = set(self.getallmd5()) repofiles = set(os.listdir(self.config.path)) - set([self.config.dbname, self.config.lastname]) dirtyfiles = repofiles - allmd5 if len(dirtyfiles) > 0: if not confirm("Remove dirty files? (yes) "): raise Exception("Aborted!") for f in dirtyfiles: p = os.path.join(self.config.path, f) try: if os.path.isdir(p): os.rmdir(p) else: os.unlink(p) except: raise Exception("Removing %s failed" % p) def delete(self, name, version): ''' Delete an image from repository Loading