bug 483800 - fix nsinstall.py to not error if a target dir already exists. r=pike
This commit is contained in:
Родитель
dbae11cb0b
Коммит
e325e1d385
|
@ -130,7 +130,8 @@ def nsinstall(argv):
|
|||
# we're supposed to copy files
|
||||
def handleTarget(srcpath, targetpath):
|
||||
if os.path.isdir(srcpath):
|
||||
os.mkdir(targetpath)
|
||||
if not os.path.exists(targetpath):
|
||||
os.mkdir(targetpath)
|
||||
entries = [os.path.join(srcpath, e) for e in os.listdir(srcpath)]
|
||||
copy_all_entries(entries, targetpath)
|
||||
# options.t is not relevant for directories
|
||||
|
|
|
@ -64,6 +64,13 @@ class TestNsinstall(unittest.TestCase):
|
|||
self.assert_(os.path.isfile(os.path.join(testdir,
|
||||
os.path.basename(f))))
|
||||
|
||||
def test_nsinstall_dir_exists(self):
|
||||
"Test nsinstall <dir> <dest dir>, where <dest dir>/<dir> already exists"
|
||||
srcdir = self.mkdirs("test")
|
||||
destdir = self.mkdirs("testdir/test")
|
||||
self.assertEqual(nsinstall([srcdir, os.path.dirname(destdir)]), 0)
|
||||
self.assert_(os.path.isdir(destdir))
|
||||
|
||||
def test_nsinstall_t(self):
|
||||
"Test that nsinstall -t works (preserve timestamp)"
|
||||
testfile = self.touch("testfile")
|
||||
|
|
|
@ -130,7 +130,8 @@ def nsinstall(argv):
|
|||
# we're supposed to copy files
|
||||
def handleTarget(srcpath, targetpath):
|
||||
if os.path.isdir(srcpath):
|
||||
os.mkdir(targetpath)
|
||||
if not os.path.exists(targetpath):
|
||||
os.mkdir(targetpath)
|
||||
entries = [os.path.join(srcpath, e) for e in os.listdir(srcpath)]
|
||||
copy_all_entries(entries, targetpath)
|
||||
# options.t is not relevant for directories
|
||||
|
|
Загрузка…
Ссылка в новой задаче