Commit 318bcd9a authored by Jim Fulton's avatar Jim Fulton

Fixed more windows issues

parent 34b1a541
...@@ -325,9 +325,8 @@ class FilesystemHelper: ...@@ -325,9 +325,8 @@ class FilesystemHelper:
os.path.join(self.base_dir, LAYOUT_MARKER), 'wb') os.path.join(self.base_dir, LAYOUT_MARKER), 'wb')
layout_marker.write(self.layout_name) layout_marker.write(self.layout_name)
else: else:
layout_marker = open( layout = open(os.path.join(self.base_dir, LAYOUT_MARKER), 'rb'
os.path.join(self.base_dir, LAYOUT_MARKER), 'rb') ).read().strip()
layout = layout_marker.read().strip()
if layout != self.layout_name: if layout != self.layout_name:
raise ValueError( raise ValueError(
"Directory layout `%s` selected for blob directory %s, but " "Directory layout `%s` selected for blob directory %s, but "
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
import logging import logging
import optparse import optparse
import os import os
import shutil
from ZODB.blob import FilesystemHelper, rename_or_copy_blob from ZODB.blob import FilesystemHelper, rename_or_copy_blob
from ZODB.utils import cp, oid_repr from ZODB.utils import cp, oid_repr
...@@ -28,6 +29,12 @@ def link_or_copy(f1, f2): ...@@ -28,6 +29,12 @@ def link_or_copy(f1, f2):
except OSError: except OSError:
shutil.copy(f1, f2) shutil.copy(f1, f2)
# Check if we actually have link
try:
os.link
except AttributeError:
link_or_copy = shutil.copy
def migrate(source, dest, layout): def migrate(source, dest, layout):
source_fsh = FilesystemHelper(source) source_fsh = FilesystemHelper(source)
......
...@@ -29,9 +29,12 @@ entries per directory level: ...@@ -29,9 +29,12 @@ entries per directory level:
>>> bushy.oid_to_path('\x00\x00\x00\x00\x00\x00\x00\x01') >>> bushy.oid_to_path('\x00\x00\x00\x00\x00\x00\x00\x01')
'0x00/0x00/0x00/0x00/0x00/0x00/0x00/0x01' '0x00/0x00/0x00/0x00/0x00/0x00/0x00/0x01'
>>> bushy.path_to_oid('0x01/0x00/0x00/0x00/0x00/0x00/0x00/0x00') >>> import os
>>> bushy.path_to_oid(os.path.join(
... '0x01', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00'))
'\x01\x00\x00\x00\x00\x00\x00\x00' '\x01\x00\x00\x00\x00\x00\x00\x00'
>>> bushy.path_to_oid('0xff/0x00/0x00/0x00/0x00/0x00/0x00/0x00') >>> bushy.path_to_oid(os.path.join(
... '0xff', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00', '0x00'))
'\xff\x00\x00\x00\x00\x00\x00\x00' '\xff\x00\x00\x00\x00\x00\x00\x00'
Paths that do not represent an OID will cause a ValueError: Paths that do not represent an OID will cause a ValueError:
...@@ -142,8 +145,8 @@ directory that has a different marker than the chosen strategy: ...@@ -142,8 +145,8 @@ directory that has a different marker than the chosen strategy:
'lawn' 'lawn'
>>> fsh.create() # doctest: +ELLIPSIS >>> fsh.create() # doctest: +ELLIPSIS
Traceback (most recent call last): Traceback (most recent call last):
ValueError: Directory layout `lawn` selected for blob directory /.../blobs/, but marker found for layout `bushy` ValueError: Directory layout `lawn` selected for blob directory .../blobs/, but marker found for layout `bushy`
>>> shutil.rmtree(blobs) >>> rmtree(blobs)
This function interacts with the automatic detection in the way, that an This function interacts with the automatic detection in the way, that an
unmarked directory will be marked the first time when it is auto-guessed and unmarked directory will be marked the first time when it is auto-guessed and
...@@ -163,10 +166,11 @@ the marker will be used in the future: ...@@ -163,10 +166,11 @@ the marker will be used in the future:
'lawn' 'lawn'
>>> blob_storage = BlobStorage(blobs, base_storage, layout='bushy') # doctest: +ELLIPSIS >>> blob_storage = BlobStorage(blobs, base_storage, layout='bushy') # doctest: +ELLIPSIS
Traceback (most recent call last): Traceback (most recent call last):
ValueError: Directory layout `bushy` selected for blob directory /.../blobs/, but marker found for layout `lawn` ValueError: Directory layout `bushy` selected for blob directory .../blobs/, but marker found for layout `lawn`
>>> shutil.rmtree(d) >>> base_storage.close()
>>> rmtree(d)
Migrating between directory layouts Migrating between directory layouts
...@@ -206,7 +210,7 @@ that shall be used for the new directory: ...@@ -206,7 +210,7 @@ that shall be used for the new directory:
>>> bushy = os.path.join(d, 'bushy') >>> bushy = os.path.join(d, 'bushy')
>>> migrate(old, bushy, 'bushy') # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE >>> migrate(old, bushy, 'bushy') # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
Migrating blob data from `/.../old` (lawn) to `/.../bushy` (bushy) Migrating blob data from `.../old` (lawn) to `.../bushy` (bushy)
OID: 0x0a - 2 files OID: 0x0a - 2 files
OID: 0x1b7a - 2 files OID: 0x1b7a - 2 files
OID: 0x1b7f - 2 files OID: 0x1b7f - 2 files
...@@ -248,7 +252,7 @@ We can also migrate the bushy layout back to the lawn layout: ...@@ -248,7 +252,7 @@ We can also migrate the bushy layout back to the lawn layout:
>>> lawn = os.path.join(d, 'lawn') >>> lawn = os.path.join(d, 'lawn')
>>> migrate(bushy, lawn, 'lawn') >>> migrate(bushy, lawn, 'lawn')
Migrating blob data from `/.../bushy` (bushy) to `/.../lawn` (lawn) Migrating blob data from `.../bushy` (bushy) to `.../lawn` (lawn)
OID: 0x0a - 2 files OID: 0x0a - 2 files
OID: 0x1b7a - 2 files OID: 0x1b7a - 2 files
OID: 0x1b7f - 2 files OID: 0x1b7f - 2 files
...@@ -278,4 +282,4 @@ bushy/0x00/0x00/0x00/0x00/0x00/0x00/0x00/0x0a/foo4 --> lawn/0x0a/foo4 ...@@ -278,4 +282,4 @@ bushy/0x00/0x00/0x00/0x00/0x00/0x00/0x00/0x0a/foo4 --> lawn/0x0a/foo4
bushy/0x00/0x00/0x00/0x00/0x00/0x00/0x1b/0x7a/foo5 --> lawn/0x1b7a/foo5 bushy/0x00/0x00/0x00/0x00/0x00/0x00/0x1b/0x7a/foo5 --> lawn/0x1b7a/foo5
bushy/0x00/0x00/0x00/0x00/0x00/0x00/0x1b/0x7a/foo6 --> lawn/0x1b7a/foo6 bushy/0x00/0x00/0x00/0x00/0x00/0x00/0x1b/0x7a/foo6 --> lawn/0x1b7a/foo6
>>> shutil.rmtree(d) >>> rmtree(d)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment