diff options
-rwxr-xr-x | server.py | 30 |
1 files changed, 27 insertions, 3 deletions
@@ -26,6 +26,8 @@ DEBUG = False #### Utils.setdebug(DEBUG) SUFFIX='drpm' +DRPMWORTHKEEPINGTHRESH=0.5 +DEBUG=0 def genDeltaRPM(ts, newrpm, oldrpm): (f1,n1,e1,v1,r1) = newrpm @@ -39,9 +41,31 @@ def genDeltaRPM(ts, newrpm, oldrpm): deltaCommand = 'makedeltarpm %s %s %s' % (f2, f1, deltaRPMName) if DEBUG: print "DEBUG " + deltaCommand - (code, out) = commands.getstatusoutput(deltaCommand) - if code: - raise Exception("genDeltaRPM: exitcode was %s - Reported Error: %s" % (code, out)) + # If the drpm doesn't exists, make it, else skip it + if not os.path.exists(deltaRPMName): + (code, out) = commands.getstatusoutput(deltaCommand) + if code: + #raise Exception("genDeltaRPM: exitcode was %s - Reported Error: %s" % (code, out)) + print "Error genDeltaRPM for %s: exitcode was %s - Reported Error: %s" % (n1, code, out) + # Check whether or not we should keep the drpm + if not drpmIsWorthKeeping(deltaRPMName, f1): + if DEBUG: + print 'deleting %s' % (deltaRPMName) + try: + os.unlink(deltaRPMName) + except Exception, e: + print "Error deleting deltarpm %s" % (deltaRPMName), str(e) + else: + if DEBUG: + print "DEBUG skipping %s" % (deltaRPMName) + +def drpmIsWorthKeeping(deltaRPMName, newrpm): + newsize = os.path.getsize(newrpm) + drpmsize = os.path.getsize(deltaRPMName) + # Delete the drpm if it's too fat + if drpmsize > DRPMWORTHKEEPINGTHRESH * newsize: + return 0 + return 1 def pruneRepo(keep,whitelist,srcdir): ts = rpmUtils.transaction.initReadOnlyTransaction() |