Address some review comments

This commit is contained in:
A.J. Beamon 2018-06-26 15:06:15 -07:00
parent 2ed452353f
commit a7158f96aa
2 changed files with 11 additions and 7 deletions

View File

@ -400,9 +400,10 @@ def generate_path(min_length=0):
def generate_prefix(require_unique=False, is_partition=False, min_length=1):
fixed_prefix = 'abcdefg'
if not require_unique and min_length == 0 and random.random() < 0.8:
return None
elif require_unique or is_partition or min_length > len('abcdefg') or random.random() < 0.5:
elif require_unique or is_partition or min_length > len(fixed_prefix) or random.random() < 0.5:
if require_unique:
min_length = max(min_length, 16)
@ -416,6 +417,6 @@ def generate_prefix(require_unique=False, is_partition=False, min_length=1):
else:
return ''.join(chr(random.randrange(ord('\x02'), ord('\x14'))) for i in range(0, length))
else:
prefix = 'abcdefg'
prefix = fixed_prefix
generated = prefix[0:random.randrange(min_length, len(prefix))]
return generated

View File

@ -3,13 +3,14 @@ import sys
class TreeNodeState:
def __init__(self, dir_id, is_directory, is_subspace, has_known_prefix, root, is_partition):
self.dir_id = dir_id
self.root = root
self.is_directory = is_directory
self.is_subspace = is_subspace
self.has_known_prefix = has_known_prefix
self.root = root
self.is_partition = is_partition
self.children = {}
self.deleted = False
self.is_partition = is_partition
class Pointer:
def __init__(self, obj):
@ -21,13 +22,15 @@ class Pointer:
def set(self, obj):
self.obj = obj
# Represents an element of the directory hierarchy, which could have multiple states
# Represents an element of the directory hierarchy. As a result of various operations (e.g. moves) that
# may or may not have succeeded, a node can represent multiple possible states.
class DirectoryStateTreeNode:
# A cache of directory layers. We mustn't have multiple entries for the same layer
layers = {}
# This is the directory that gets used if the chosen directory is invalid
# We must assume any operation could also have been applied to it
# Because our operations may be applied to the default directory in the case that
# the current directory failed to open/create, we compute the result of each operation
# as if it was performed on the current directory and the default directory.
default_directory = None
# Used for debugging