bug 483800 - fix nsinstall.py to not error if a target dir already exists. r=pike

This commit is contained in:
Ted Mielczarek 2009-03-17 12:09:50 -04:00
Родитель dbae11cb0b
Коммит e325e1d385
3 изменённых файлов: 11 добавлений и 2 удалений

Просмотреть файл

@ -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