Real fix for #6748: The exception is raised both in getcwd() and chdir()

BUG:COMMENT:6748
This commit is contained in:
Ozan Çağlayan
2010-02-11 21:07:01 +00:00
parent f2a15f39ba
commit 308aa49ba6
2 changed files with 13 additions and 4 deletions
+4
View File
@@ -0,0 +1,4 @@
pisi 2.2.19 (??/02/2010)
-------------------------
#6748 - pisi fails to install a package when CWD doesn't exist anymore (real fix)
+9 -4
View File
@@ -13,7 +13,6 @@
"""Archive module provides access to regular archive file types."""
# standard library modules
import exceptions
import os
import stat
import shutil
@@ -153,7 +152,12 @@ class ArchiveTar(ArchiveBase):
raise UnknownArchiveType
self.tar = tarfile.open(self.file_path, rmode)
oldwd = os.getcwd()
oldwd = None
try:
# Don't fail if CWD doesn't exist (#6748)
oldwd = os.getcwd()
except OSError:
pass
os.chdir(target_dir)
uid = os.getuid()
@@ -203,9 +207,10 @@ class ArchiveTar(ArchiveBase):
os.unlink(self.file_path)
try:
os.chdir(oldwd)
if oldwd:
os.chdir(oldwd)
# Bug #6748
except exceptions.OSError:
except OSError:
pass
self.close()