|
|
@@ -79,7 +79,12 @@ class BulkData(object): |
|
|
|
if Table.exists(ospath): |
|
|
|
raise ValueError("stream already exists at this path") |
|
|
|
if os.path.isdir(ospath): |
|
|
|
raise ValueError("subdirs of this path already exist") |
|
|
|
# Look for any files in subdirectories. Fully empty subdirectories |
|
|
|
# are OK; they might be there during a rename |
|
|
|
for (root, dirs, files) in os.walk(ospath): |
|
|
|
if len(files): |
|
|
|
raise ValueError( |
|
|
|
"non-empty subdirs of this path already exist") |
|
|
|
|
|
|
|
def _create_parents(self, unicodepath): |
|
|
|
"""Verify the path name, and create parent directories if they |
|
|
@@ -188,7 +193,6 @@ class BulkData(object): |
|
|
|
# Basic checks |
|
|
|
if oldospath == newospath: |
|
|
|
raise ValueError("old and new paths are the same") |
|
|
|
self._create_check_ospath(newospath) |
|
|
|
|
|
|
|
# Move the table to a temporary location |
|
|
|
tmpdir = tempfile.mkdtemp(prefix = "rename-", dir = self.root) |
|
|
@@ -196,6 +200,9 @@ class BulkData(object): |
|
|
|
os.rename(oldospath, tmppath) |
|
|
|
|
|
|
|
try: |
|
|
|
# Check destination path |
|
|
|
self._create_check_ospath(newospath) |
|
|
|
|
|
|
|
# Create parent dirs for new location |
|
|
|
self._create_parents(newunicodepath) |
|
|
|
|
|
|
|