forked from seba/servefile
Added cleanup for temp directories
This commit is contained in:
parent
771d383b81
commit
d46cc10107
11
servefile
11
servefile
|
@ -189,10 +189,13 @@ def main():
|
|||
handler = FilePutter
|
||||
|
||||
server = ThreadedHTTPServer(('', args.port), handler)
|
||||
if args.upload:
|
||||
print "Serving \"%s\" under port %d" % (args.filename, args.port)
|
||||
else:
|
||||
print "Serving \"%s\" for uploads under port %d" % (args.filename, args.port)
|
||||
|
||||
# print urls with local network adresses
|
||||
print "\nSome addresses this file will be available under:"
|
||||
print "\nSome addresses this will be available under:"
|
||||
|
||||
# ip and ifconfig sometimes are located in /sbin/
|
||||
os.environ['PATH'] += ':/sbin:/usr/sbin'
|
||||
|
@ -229,8 +232,12 @@ def main():
|
|||
server.serve_forever()
|
||||
except KeyboardInterrupt:
|
||||
server.socket.close()
|
||||
|
||||
# cleanup potential upload directory
|
||||
if dirCreated and len(os.listdir(args.filename)) == 0:
|
||||
# created upload dir was not used
|
||||
os.rmdir(args.filename)
|
||||
print "Good bye.."
|
||||
# XXX: cleanup upload directory
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
Loading…
Reference in New Issue