diff --git a/TODO b/TODO index d6a6e1437..6b210a2a2 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,7 @@ TODO list: - reagent: complete smartapps section CLIENT: - - on disk caching for all user commands - - implement logTools into new Equo functions (especially messages) + - implement logTools into new Equo functions (especially messages) --> messages should go into equo.log - during removal/add handle (trigger functions): - complete preremove() - complete postremove() @@ -21,6 +20,7 @@ TODO list: - equo conf update: - automerge trivial changes - automerge comments changes + - maybe on-disk cache for removal functions? Project Status: - entropy: will handle all the three tools below diff --git a/client/equo b/client/equo index 085d463db..97064973a 100644 --- a/client/equo +++ b/client/equo @@ -156,6 +156,8 @@ try: if len(scandata) > 0: print_warning(darkgreen("There are "+str(len(scandata))+" configuration file(s) that need(s) to be updated.")) print_warning(red("Please run: ")+bold("equo conf update")) + # save caches + equoTools.saveCaches() sys.exit(rc) elif (options[0] == "query"): diff --git a/client/equoTools.py b/client/equoTools.py index 73c3b8853..07eaeaac7 100644 --- a/client/equoTools.py +++ b/client/equoTools.py @@ -33,6 +33,7 @@ from entropyTools import unpackGzip, compareMd5, bytesIntoHuman, convertUnixTime from databaseTools import etpDatabase import triggerTools import confTools +import dumpTools import xpak import time @@ -40,14 +41,20 @@ import time import logTools equoLog = logTools.LogFile(level = etpConst['equologlevel'],filename = etpConst['equologfile'], header = "[Equo]") -global atomMatchCache -atomMatchCache = {} -global atomClientMatchCache -atomClientMatchCache = {} -global contentCache -contentCache = {} -global getDependenciesCache -getDependenciesCache = {} +### Caching functions + +def loadCaches(): + print_info(darkred(" @@ ")+blue("Loading On-Disk Cache...")) + mycache = dumpTools.loadobj(etpCache['atomMatch']) + if isinstance(mycache, dict): + global atomMatchCache + atomMatchCache = mycache.copy() + #print "loadCaches: "+str(len(atomMatchCache)) + +def saveCaches(): + # atomMatchCache + dumpTools.dumpobj(etpCache['atomMatch'],atomMatchCache) + #print "saveCaches: "+str(len(atomMatchCache)) ######################################################## #### @@ -206,6 +213,10 @@ def syncRepositories(reponames = [], forceUpdate = False, quiet = False): syncErrors = True continue + # clear repository cache + atomMatchCache.clear() + dumpTools.dumpobj(etpCache['atomMatch'],atomMatchCache) + # starting to download if (not quiet): print_info(red("\tDownloading database ")+darkgreen(etpConst['etpdatabasefilegzip'])+red(" ...")) @@ -1489,9 +1500,6 @@ def installPackageIntoDatabase(idpackage, repository): print "DEBUG!!! dependstable not found" clientDbconn.regenerateDependsTable() - # reset atomMatch cache - atomMatchCache.clear() - closeClientDatabase(clientDbconn) return exitstatus @@ -1520,8 +1528,6 @@ def removePackageFromDatabase(idpackage): pass clientDbconn.removePackage(idpackage) - # reset atomMatch cache - atomMatchCache = {} closeClientDatabase(clientDbconn) return 0 @@ -1577,10 +1583,12 @@ def package(options): myopts = _myopts if (options[0] == "deptest"): + loadCaches() rc, garbage = dependenciesTest(quiet = equoRequestQuiet, ask = equoRequestAsk, pretend = equoRequestPretend) elif (options[0] == "install"): if len(myopts) > 0: + loadCaches() rc, status = installPackages(myopts, ask = equoRequestAsk, pretend = equoRequestPretend, verbose = equoRequestVerbose, deps = equoRequestDeps, emptydeps = equoRequestEmptyDeps, onlyfetch = equoRequestOnlyFetch, deepdeps = equoRequestDeep, configFiles = equoRequestConfigFiles) else: print_error(red(" Nothing to do.")) @@ -1592,10 +1600,12 @@ def package(options): for opt in myopts: if opt == "upgrade": doupgrade = True + loadCaches() rc, status = worldUpdate(ask = equoRequestAsk, pretend = equoRequestPretend, verbose = equoRequestVerbose, onlyfetch = equoRequestOnlyFetch, upgrade = doupgrade) elif (options[0] == "remove"): if len(myopts) > 0: + loadCaches() rc, status = removePackages(myopts, ask = equoRequestAsk, pretend = equoRequestPretend, verbose = equoRequestVerbose, deps = equoRequestDeps, deep = equoRequestDeep, configFiles = equoRequestConfigFiles) else: print_error(red(" Nothing to do.")) diff --git a/libraries/clientConstants.py b/libraries/clientConstants.py index f15e67155..9e250c4eb 100644 --- a/libraries/clientConstants.py +++ b/libraries/clientConstants.py @@ -35,6 +35,16 @@ etpInstallTriggers = {} ### structure same as above etpRemovalTriggers = {} +### Application disk cache +global atomMatchCache +atomMatchCache = {} +global atomClientMatchCache +atomClientMatchCache = {} +global contentCache +contentCache = {} +global getDependenciesCache +getDependenciesCache = {} + # Client packages/database repositories # used by equo etpRepositories = {} diff --git a/libraries/entropyConstants.py b/libraries/entropyConstants.py index ec41c1cd2..e6ed1476b 100644 --- a/libraries/entropyConstants.py +++ b/libraries/entropyConstants.py @@ -391,6 +391,7 @@ etpConst = { # disk caching dictionary etpCache = { 'configfiles': 'scanfs', # used to store information about files that should be merged using "equo conf merge" + 'atomMatch': 'atomMatchCache', # used to store info about repository dependencies solving } # handle Entropy Version