Real fix for #6748: The exception is raised both in getcwd() and chdir()
BUG:COMMENT:6748
This commit is contained in:
@@ -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
@@ -13,7 +13,6 @@
|
|||||||
"""Archive module provides access to regular archive file types."""
|
"""Archive module provides access to regular archive file types."""
|
||||||
|
|
||||||
# standard library modules
|
# standard library modules
|
||||||
import exceptions
|
|
||||||
import os
|
import os
|
||||||
import stat
|
import stat
|
||||||
import shutil
|
import shutil
|
||||||
@@ -153,7 +152,12 @@ class ArchiveTar(ArchiveBase):
|
|||||||
raise UnknownArchiveType
|
raise UnknownArchiveType
|
||||||
|
|
||||||
self.tar = tarfile.open(self.file_path, rmode)
|
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)
|
os.chdir(target_dir)
|
||||||
|
|
||||||
uid = os.getuid()
|
uid = os.getuid()
|
||||||
@@ -203,9 +207,10 @@ class ArchiveTar(ArchiveBase):
|
|||||||
os.unlink(self.file_path)
|
os.unlink(self.file_path)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.chdir(oldwd)
|
if oldwd:
|
||||||
|
os.chdir(oldwd)
|
||||||
# Bug #6748
|
# Bug #6748
|
||||||
except exceptions.OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user