mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-06-22 16:58:58 +00:00
storage: remove the leftover incoming/XYZ/ directory when we're done with it
This commit is contained in:
@ -195,6 +195,12 @@ class BucketWriter(Referenceable):
|
|||||||
filelen = os.stat(self.finalhome)[stat.ST_SIZE]
|
filelen = os.stat(self.finalhome)[stat.ST_SIZE]
|
||||||
self.ss.bucket_writer_closed(self, filelen)
|
self.ss.bucket_writer_closed(self, filelen)
|
||||||
|
|
||||||
|
# if we were the last share to be moved, remove the incoming/
|
||||||
|
# directory that was our parent
|
||||||
|
parentdir = os.path.split(self.incominghome)[0]
|
||||||
|
if not os.listdir(parentdir):
|
||||||
|
os.rmdir(parentdir)
|
||||||
|
|
||||||
|
|
||||||
class BucketReader(Referenceable):
|
class BucketReader(Referenceable):
|
||||||
implements(RIBucketReader)
|
implements(RIBucketReader)
|
||||||
|
@ -202,6 +202,17 @@ class Server(unittest.TestCase):
|
|||||||
renew_secret, cancel_secret,
|
renew_secret, cancel_secret,
|
||||||
sharenums, size, Referenceable())
|
sharenums, size, Referenceable())
|
||||||
|
|
||||||
|
def test_remove_incoming(self):
|
||||||
|
ss = self.create("test_remove_incoming")
|
||||||
|
already, writers = self.allocate(ss, "vid", range(3), 10)
|
||||||
|
for i,wb in writers.items():
|
||||||
|
wb.remote_write(0, "%10d" % i)
|
||||||
|
wb.remote_close()
|
||||||
|
incomingdir = os.path.join(self.workdir("test_remove_incoming"),
|
||||||
|
"shares", "incoming")
|
||||||
|
leftover_dirs = os.listdir(incomingdir)
|
||||||
|
self.failUnlessEqual(leftover_dirs, [])
|
||||||
|
|
||||||
def test_allocate(self):
|
def test_allocate(self):
|
||||||
ss = self.create("test_allocate")
|
ss = self.create("test_allocate")
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user