summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmed Kamal <email.ahmedkamal@googlemail.com>2007-02-14 00:23:16 +0200
committerAhmed Kamal <email.ahmedkamal@googlemail.com>2007-02-14 00:23:16 +0200
commiteee8adadcd4fc3c0d7deea4a8ada73b4278c61f4 (patch)
treed592175e64a4e4cf1014e4726b9d6695fc2e92b3
parent6c4f9793d90e759522507a0bb4ef638e6c3215c1 (diff)
downloadpresto-eee8adadcd4fc3c0d7deea4a8ada73b4278c61f4.zip
presto-eee8adadcd4fc3c0d7deea4a8ada73b4278c61f4.tar.gz
presto-eee8adadcd4fc3c0d7deea4a8ada73b4278c61f4.tar.xz
Implement drpmIsWorthKeeping, and only generate a drpm if it's not already
there.
-rwxr-xr-xserver.py30
1 files changed, 27 insertions, 3 deletions
diff --git a/server.py b/server.py
index c7bfe4c..c3651fc 100755
--- a/server.py
+++ b/server.py
@@ -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()