Merge lp:~mandel/ubuntuone-windows-installer/u1sync_long_paths into lp:ubuntuone-windows-installer/beta

Proposed by Manuel de la Peña
Status: Merged
Approved by: Manuel de la Peña
Approved revision: 134
Merged at revision: 112
Proposed branch: lp:~mandel/ubuntuone-windows-installer/u1sync_long_paths
Merge into: lp:ubuntuone-windows-installer/beta
Diff against target: 134 lines (+19/-14)
5 files modified
src/u1sync/client.py (+7/-6)
src/u1sync/merge.py (+1/-1)
src/u1sync/metadata.py (+7/-3)
src/u1sync/scan.py (+3/-3)
src/u1sync/sync.py (+1/-1)
To merge this branch: bzr merge lp:~mandel/ubuntuone-windows-installer/u1sync_long_paths
Reviewer Review Type Date Requested Status
Ubuntu One hackers Pending
Review via email: mp+39901@code.launchpad.net

Description of the change

Allow u1sync to use long pats by using \\?\

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/u1sync/client.py'
--- src/u1sync/client.py 2010-09-27 17:33:52 +0000
+++ src/u1sync/client.py 2010-11-02 21:57:45 +0000
@@ -565,15 +565,15 @@
565 """Downloads a file from the server."""565 """Downloads a file from the server."""
566 # file names have to be quoted to make sure that no issues occur when566 # file names have to be quoted to make sure that no issues occur when
567 # spaces exist567 # spaces exist
568 partial_filename = "%s.u1partial" % filename568 partial_filename = "\\\\?\\%s.u1partial" % filename
569 output = open(partial_filename, "w")569 output = open(partial_filename, "wb")
570570
571 @log_timing571 @log_timing
572 def rename_file():572 def rename_file():
573 """Renames the temporary file to the final name."""573 """Renames the temporary file to the final name."""
574 output.close()574 output.close()
575 print "Finished downloading %s" % filename575 print "Finished downloading %s" % filename
576 os.rename(partial_filename, filename)576 os.rename(partial_filename, "\\\\?\\" + filename)
577577
578 @log_timing578 @log_timing
579 def delete_file():579 def delete_file():
@@ -688,9 +688,9 @@
688 self.compressed_size += len(compressed_bytes)688 self.compressed_size += len(compressed_bytes)
689 self.stream.write(compressed_bytes)689 self.stream.write(compressed_bytes)
690690
691 with open(unique_filename, "w+") as compressed:691
692 os.unlink(unique_filename)692 with open("\\\\?\\" + unique_filename, "wb+") as compressed:
693 with open(filename, "r") as original:693 with open("\\\\?\\" + filename, "rb") as original:
694 staging = StagingFile(compressed)694 staging = StagingFile(compressed)
695 shutil.copyfileobj(original, staging)695 shutil.copyfileobj(original, staging)
696 staging.finish()696 staging.finish()
@@ -701,6 +701,7 @@
701 staging.crc32,701 staging.crc32,
702 staging.size, staging.compressed_size,702 staging.size, staging.compressed_size,
703 compressed)703 compressed)
704 os.unlink("\\\\?\\" + unique_filename)
704705
705 @log_timing706 @log_timing
706 def move(self, share_uuid, parent_uuid, name, node_uuid):707 def move(self, share_uuid, parent_uuid, name, node_uuid):
707708
=== modified file 'src/u1sync/merge.py'
--- src/u1sync/merge.py 2010-08-27 14:43:32 +0000
+++ src/u1sync/merge.py 2010-11-02 21:57:45 +0000
@@ -42,7 +42,7 @@
42 old_local_node, local_node, old_remote_node, remote_node = nodes42 old_local_node, local_node, old_remote_node, remote_node = nodes
43 # pylint: disable-msg=W061243 # pylint: disable-msg=W0612
44 (parent_path, parent_type) = partial_parent44 (parent_path, parent_type) = partial_parent
45 path = os.path.join(parent_path, name.encode("utf-8"))45 path = os.path.join(parent_path, name)
46 node_type = merge_action.get_node_type(old_local_node=old_local_node,46 node_type = merge_action.get_node_type(old_local_node=old_local_node,
47 local_node=local_node,47 local_node=local_node,
48 old_remote_node=old_remote_node,48 old_remote_node=old_remote_node,
4949
=== modified file 'src/u1sync/metadata.py'
--- src/u1sync/metadata.py 2010-08-27 14:43:32 +0000
+++ src/u1sync/metadata.py 2010-11-02 21:57:45 +0000
@@ -116,7 +116,7 @@
116def read_string_file(filename, default_value=None):116def read_string_file(filename, default_value=None):
117 """Reads a string from a file, discarding the final character."""117 """Reads a string from a file, discarding the final character."""
118 try:118 try:
119 with open(filename, "r") as stream:119 with open(filename, "rb") as stream:
120 return stream.read()[:-1]120 return stream.read()[:-1]
121 except IOError, e:121 except IOError, e:
122 if e.errno != ENOENT:122 if e.errno != ENOENT:
@@ -126,7 +126,7 @@
126def read_uuid_file(filename, default_value=None):126def read_uuid_file(filename, default_value=None):
127 """Reads a UUID from a file."""127 """Reads a UUID from a file."""
128 try:128 try:
129 with open(filename, "r") as stream:129 with open(filename, "rb") as stream:
130 return uuid.UUID(stream.read()[:-1])130 return uuid.UUID(stream.read()[:-1])
131 except IOError, e:131 except IOError, e:
132 if e.errno != ENOENT:132 if e.errno != ENOENT:
@@ -138,8 +138,12 @@
138 """Returns a context manager for atomically updating a file."""138 """Returns a context manager for atomically updating a file."""
139 temp_filename = "%s.%s" % (filename, uuid.uuid4())139 temp_filename = "%s.%s" % (filename, uuid.uuid4())
140 try:140 try:
141 with open(temp_filename, "w") as stream:141 with open(temp_filename, "wb") as stream:
142 yield stream142 yield stream
143 if os.path.exists(filename):
144 # windows does not have atomic updates
145 # of files
146 os.remove(filename)
143 os.rename(temp_filename, filename)147 os.rename(temp_filename, filename)
144 finally:148 finally:
145 safe_unlink(temp_filename)149 safe_unlink(temp_filename)
146150
=== modified file 'src/u1sync/scan.py'
--- src/u1sync/scan.py 2010-08-27 14:43:32 +0000
+++ src/u1sync/scan.py 2010-11-02 21:57:45 +0000
@@ -75,13 +75,13 @@
75 return MergeNode(node_type=SYMLINK, content_hash=content_hash)75 return MergeNode(node_type=SYMLINK, content_hash=content_hash)
76 elif child_names is not None:76 elif child_names is not None:
77 # directory77 # directory
78 child_names = [n for n in child_names if should_sync(n.decode("utf-8"))]78 child_names = [n for n in child_names if should_sync(n)]
79 child_paths = [(os.path.join(path, child_name),79 child_paths = [(os.path.join(path, child_name),
80 os.path.join(display_path, child_name)) \80 os.path.join(display_path, child_name)) \
81 for child_name in child_names]81 for child_name in child_names]
82 children = [scan_directory(child_path, child_display_path, quiet) \82 children = [scan_directory(child_path, child_display_path, quiet) \
83 for (child_path, child_display_path) in child_paths]83 for (child_path, child_display_path) in child_paths]
84 unicode_child_names = [n.decode("utf-8") for n in child_names]84 unicode_child_names = [n for n in child_names]
85 children = dict(zip(unicode_child_names, children))85 children = dict(zip(unicode_child_names, children))
86 return MergeNode(node_type=DIRECTORY, children=children)86 return MergeNode(node_type=DIRECTORY, children=children)
87 else:87 else:
@@ -96,7 +96,7 @@
96 sum.update(bytes)96 sum.update(bytes)
9797
9898
99 with open(path, "r") as stream:99 with open("\\\\?\\" + path, "rb") as stream:
100 shutil.copyfileobj(stream, HashStream())100 shutil.copyfileobj(stream, HashStream())
101 content_hash = "sha1:%s" % sum.hexdigest()101 content_hash = "sha1:%s" % sum.hexdigest()
102 return MergeNode(node_type=FILE, content_hash=content_hash)102 return MergeNode(node_type=FILE, content_hash=content_hash)
103103
=== modified file 'src/u1sync/sync.py'
--- src/u1sync/sync.py 2010-08-27 14:43:32 +0000
+++ src/u1sync/sync.py 2010-11-02 21:57:45 +0000
@@ -75,7 +75,7 @@
75 (parent_path, parent_display_path, parent_uuid, parent_synced) \75 (parent_path, parent_display_path, parent_uuid, parent_synced) \
76 = partial_parent76 = partial_parent
7777
78 utf8_name = name.encode("utf-8")78 utf8_name = name
79 path = os.path.join(parent_path, utf8_name)79 path = os.path.join(parent_path, utf8_name)
80 display_path = os.path.join(parent_display_path, utf8_name)80 display_path = os.path.join(parent_display_path, utf8_name)
81 node_uuid = None81 node_uuid = None

Subscribers

People subscribed via source and target branches

to all changes: