Closed GoogleCodeExporter closed 9 years ago
This is not a bug, maybe just an omission in documentation. To release the hold
of the file you were reading, you need to close it first. With RarFile objects
here it is done via deleting. Thus, you should simply add a line "del rar"
before your "shutil.move" call.
Original comment by yk4e...@gmail.com
on 20 Jun 2010 at 9:50
Adding "del rar" before moving the archive doesn't seem to do anything for me.
I still get the exact same error when I try to move it.
Original comment by WildBama...@gmail.com
on 20 Jun 2010 at 6:31
Attachments:
Hmm. Will take a look at it.
Original comment by yk4e...@gmail.com
on 20 Jun 2010 at 10:01
Yes, we still have one more reference to the RarFile object, it's in
"fileInArchive" variable that's still alive after the for loop. I probably
should convert it to weakref...
Can you try to rewrite the loop like this and see if it helps:
rar = UnRAR2.RarFile(filename)
found = False
print "\n-------------"
print "Installing..."
print "-------------\n"
for fileInArchive in rar.infoiter():
file = os.path.split(fileInArchive.filename)[-1]
basename, ext = os.path.splitext(file)
if ext == ".txt":
print "Found %s. Extracting to My Documents..." % file
rar.extract("*.txt", desktop)
found = True
del fileInArchive
del rar
Original comment by yk4e...@gmail.com
on 22 Jun 2010 at 3:03
Just tested that, works just fine now.
Original comment by WildBama...@gmail.com
on 22 Jun 2010 at 3:27
Attention: the problem (reference leak) was re-introduced in version 0.99.1.
Unfortunately, even "del" won't help this time.
Will be fixed in 0.99.2.
Original comment by yk4e...@gmail.com
on 9 Sep 2010 at 2:49
Original comment by yk4e...@gmail.com
on 9 Sep 2010 at 2:50
Released 0.99.2 with the fix
Original comment by yk4e...@gmail.com
on 9 Sep 2010 at 2:58
Original issue reported on code.google.com by
WildBama...@gmail.com
on 18 Jun 2010 at 2:02Attachments: