summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xtupkg/server/tupkgs26
-rw-r--r--tupkg/server/tupkgs.conf2
2 files changed, 17 insertions, 11 deletions
diff --git a/tupkg/server/tupkgs b/tupkg/server/tupkgs
index 691ab123..83925d20 100755
--- a/tupkg/server/tupkgs
+++ b/tupkg/server/tupkgs
@@ -30,15 +30,13 @@ import os.path
import os
import time
-CACHEDIR = '/var/cache/tupkgs/'
-INCOMINGDIR = '/var/cache/tupkgs/incomplete/'
CONFIGFILE = '/etc/tupkgs.conf'
config = ConfigParser.ConfigParser()
class ClientFile:
def __init__(self, filename, actual_size, actual_md5):
- self.pathname = INCOMINGDIR + filename
+ self.pathname = confdict['incomingdir'] + filename
self.filename = filename
self.fd = open(self.pathname, "a+b")
self.actual_size = actual_size
@@ -64,7 +62,7 @@ class ClientFile:
def finishDownload(self):
self.fd.close()
- newpathname = CACHEDIR + self.filename
+ newpathname = confdict['cachedir'] + self.filename
os.rename(self.pathname, newpathname)
self.pathname = newpathname
self.fd = open(self.pathname, "a+b")
@@ -229,6 +227,8 @@ def usage(name):
def getDefaultConfig():
confdict = {}
confdict['port'] = 1034
+ confdict['cachedir'] = '/var/cache/tupkgs/'
+ confdict['incomingdir'] = '/var/cache/tupkgs/incomplete/'
confdict['maxqueue'] = 5
return confdict
@@ -267,6 +267,10 @@ def main(argv=None):
confdict['port'] = config.getint('tupkgs', 'port')
if config.has_option('tupkgs', 'maxqueue'):
confdict['maxqueue'] = config.getint('tupkgs', 'maxqueue')
+ if config.has_option('tupkgs', 'cachedir'):
+ confdict['cachedir'] = config.get('tupkgs', 'cachedir')
+ if config.has_option('tupkgs', 'incomingdir'):
+ confdict['incomingdir'] = config.get('tupkgs', 'incomingdir')
print "Connecting to MySQL database"
dbconn = MySQLdb.connect(host=config.get('mysql', 'host'),
@@ -274,13 +278,13 @@ def main(argv=None):
passwd=config.get('mysql', 'password'),
db=config.get('mysql', 'db'))
- print "Verifying "+CACHEDIR+" and "+INCOMINGDIR+" exist"
- if not os.path.isdir(CACHEDIR):
- print "Creating "+CACHEDIR
- os.mkdir(CACHEDIR, 0755)
- if not os.path.isdir(INCOMINGDIR):
- print "Creating "+INCOMINGDIR
- os.mkdir(INCOMINGDIR, 0755)
+ print "Verifying "+confdict['cachedir']+" and "+confdict['incomingdir']+" exist"
+ if not os.path.isdir(confdict['cachedir']):
+ print "Creating "+confdict['cachedir']
+ os.mkdir(confdict['cachedir'], 0755)
+ if not os.path.isdir(confdict['incomingdir']):
+ print "Creating "+confdict['incomingdir']
+ os.mkdir(confdict['incomingdir'], 0755)
print "Starting ServerSocket"
servsock = ServerSocket(dbconn, confdict['port'], confdict['maxqueue'])
diff --git a/tupkg/server/tupkgs.conf b/tupkg/server/tupkgs.conf
index ab31db95..844505fb 100644
--- a/tupkg/server/tupkgs.conf
+++ b/tupkg/server/tupkgs.conf
@@ -1,5 +1,7 @@
[tupkgs]
port = 1034
+cachedir = '/var/cache/tupkgs/'
+incomingdir = '/var/cache/tupkgs/incomplete/'
[mysql]
username = aur