diff options
author | Ajay Garg <ajay@activitycentral.com> | 2012-08-28 09:40:08 (GMT) |
---|---|---|
committer | Ajay Garg <ajay@activitycentral.com> | 2012-08-28 09:40:08 (GMT) |
commit | 11890d66cf09774862d79213c0de7a4838d62418 (patch) | |
tree | 6e288fd1f99b10f9a559886cf3951ce14e34b4a1 | |
parent | 945a8ac199c31459a6a074de942b2780c00b5439 (diff) |
[Version-3] 1-to-N feature via School-Server.
Changes of version-3 over version-2 :
======================================
a)
Downloading from School-Server to "Documents" and Mounted-Drives, was
failing on XOs, with OSError code 13 (invalid cross-device link).
Surprisingly, the same worked perfectly on sugar-jhbuild :|
b)
In yesterday's version-2 commit (uploading from nested directories from
"Documents" and Mounted-Drives), a regression was introduced, wherein
the secret passphrase was not being stored on the school-server, when
the entries were uploaded from the Journal.
Fixed it.
-rw-r--r-- | rpms/sugar/0130-1-to-N-feature-via-School-Server.patch | 108 |
1 files changed, 67 insertions, 41 deletions
diff --git a/rpms/sugar/0130-1-to-N-feature-via-School-Server.patch b/rpms/sugar/0130-1-to-N-feature-via-School-Server.patch index b03c8fd..6efa2fc 100644 --- a/rpms/sugar/0130-1-to-N-feature-via-School-Server.patch +++ b/rpms/sugar/0130-1-to-N-feature-via-School-Server.patch @@ -1,7 +1,7 @@ -From 011c4b94fe4d3caf3b2ada5ab55bf12e2507e78c Mon Sep 17 00:00:00 2001 +From 4c90d19f1f033e5b5e885d333ad94b3fad9e780a Mon Sep 17 00:00:00 2001 From: Ajay Garg <ajay@activitycentral.com> -Date: Mon, 27 Aug 2012 16:40:48 +0530 -Subject: [PATCH] [Version-13] 1-to-N feature via School Server +Date: Tue, 28 Aug 2012 14:51:02 +0530 +Subject: [PATCH] www Organization: Sugar Labs Foundation @@ -9,15 +9,15 @@ Signed-off-by: Ajay Garg <ajay@activitycentral.com> --- src/jarabe/journal/journalactivity.py | 17 ++- src/jarabe/journal/journaltoolbox.py | 44 +++++- - src/jarabe/journal/model.py | 313 +++++++++++++++++++++------------ - src/jarabe/journal/palettes.py | 202 ++++++++++++++++++--- + src/jarabe/journal/model.py | 331 ++++++++++++++++++++++----------- + src/jarabe/journal/palettes.py | 202 +++++++++++++++++--- src/jarabe/journal/volumestoolbar.py | 41 ++--- src/jarabe/journal/webdavmanager.py | 146 +++++++++------ src/jarabe/view/palettes.py | 31 +--- src/webdav/Connection.py | 11 +- src/webdav/WebdavClient.py | 16 ++- src/webdav/davlib.py | 9 +- - 10 files changed, 557 insertions(+), 273 deletions(-) + 10 files changed, 575 insertions(+), 273 deletions(-) diff --git a/src/jarabe/journal/journalactivity.py b/src/jarabe/journal/journalactivity.py index fc4773d..5f2a734 100644 @@ -154,7 +154,7 @@ index 6b2494e..b1c0cac 100644 return self._selected_entries diff --git a/src/jarabe/journal/model.py b/src/jarabe/journal/model.py -index 422e947..b1514f1 100644 +index 422e947..6118aaa 100644 --- a/src/jarabe/journal/model.py +++ b/src/jarabe/journal/model.py @@ -43,7 +43,7 @@ from sugar import dispatch @@ -463,7 +463,20 @@ index 422e947..b1514f1 100644 return object_id -@@ -876,41 +948,17 @@ def _rename_entry_on_external_device(file_path, destination_path, +@@ -861,7 +933,11 @@ def _rename_entry_on_external_device(file_path, destination_path, + """Rename an entry with the associated metadata on an external device.""" + old_file_path = file_path + if old_file_path != destination_path: +- os.rename(file_path, destination_path) ++ # Strangely, "os.rename" works fine on sugar-jhbuild, but fails ++ # on XOs, wih the OSError 13 ("invalid cross-device link"). So, ++ # using the system call "mv". ++ os.system('mv "%s" "%s"' % (file_path, destination_path)) ++ + old_fname = os.path.basename(file_path) + old_files = [os.path.join(metadata_dir_path, + old_fname + '.metadata'), +@@ -876,41 +952,31 @@ def _rename_entry_on_external_device(file_path, destination_path, 'for file=%s', ofile, old_fname) @@ -478,15 +491,24 @@ index 422e947..b1514f1 100644 - This function handles renames of an entry on the - external device and avoids name collisions. Renames are - handled failsafe. -- ++def _write_metadata_and_preview_files_and_return_file_paths(metadata, ++ file_name): ++ metadata_copy = metadata.copy() ++ metadata_copy.pop('mountpoint', None) ++ metadata_copy.pop('uid', None) + - """ - if 'uid' in metadata and os.path.exists(metadata['uid']): - file_path = metadata['uid'] -- + - if not file_path or not os.path.exists(file_path): - raise ValueError('Entries without a file cannot be copied to ' - 'removable devices') -- ++ # For copying to School-Server, we need to retain this property. ++ # Else wise, I have no idea why this property is being removed !! ++ if metadata.get('mountpoint', '/') != WEBDAV_MOUNT_POINT: ++ metadata_copy.pop('filesize', None) + - if not metadata.get('title'): - metadata['title'] = _('Untitled') - file_name = get_file_name(metadata['title'], metadata['mime_type']) @@ -497,23 +519,27 @@ index 422e947..b1514f1 100644 - destination_path = os.path.join(metadata['mountpoint'], file_name) - clean_name, extension_ = os.path.splitext(file_name) - metadata['title'] = clean_name -- -+def _write_metadata_and_preview_files_and_return_file_paths(metadata, -+ file_name): - metadata_copy = metadata.copy() - metadata_copy.pop('mountpoint', None) - metadata_copy.pop('uid', None) ++ # For journal case, there is the special treatment. ++ if metadata.get('mountpoint', '/') == '/': ++ if metadata.get('uid', ''): ++ object_id = _get_datastore().update(metadata['uid'], ++ dbus.Dictionary(metadata), ++ '', ++ False) ++ else: ++ object_id = _get_datastore().create(dbus.Dictionary(metadata), ++ '', ++ False) ++ return + +- metadata_copy = metadata.copy() +- metadata_copy.pop('mountpoint', None) +- metadata_copy.pop('uid', None) - metadata_copy.pop('filesize', None) -+ -+ -+ # For copying to School-Server, we need to retain this property. -+ # Else wise, I have no idea why this property is being removed !! -+ if metadata.get('mountpoint', '/') != WEBDAV_MOUNT_POINT: -+ metadata_copy.pop('filesize', None) metadata_dir_path = os.path.join(metadata['mountpoint'], JOURNAL_METADATA_DIR) -@@ -939,25 +987,64 @@ def _write_entry_on_external_device(metadata, file_path): +@@ -939,25 +1005,64 @@ def _write_entry_on_external_device(metadata, file_path): os.close(fh) os.rename(fn, os.path.join(metadata_dir_path, preview_fname)) @@ -526,21 +552,10 @@ index 422e947..b1514f1 100644 - _rename_entry_on_external_device(file_path, destination_path, - metadata_dir_path) + preview_destination_path = None - -- # For "Shares" folder, we need to set the permissions of the newly -- # copied file to 0777, else it will not be accessible by "httpd" -- # service. -- if metadata['mountpoint'] == '/var/www/web1/web': -- fd = os.open(destination_path, os.O_RDONLY) -- os.fchmod(fd, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) -- os.close(fd) ++ + return (metadata_destination_path, preview_destination_path) - -- metadata_file_path = os.path.join(metadata_dir_path, file_name + '.metadata') -- fd = os.open(metadata_file_path, os.O_RDONLY) -- os.fchmod(fd, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) -- os.close(fd) - ++ ++ +def update_only_metadata_and_preview_files_and_return_file_paths(metadata): + file_name = get_file_name(metadata['title'], metadata['mime_type']) + _write_metadata_and_preview_files_and_return_file_paths(metadata, @@ -551,11 +566,22 @@ index 422e947..b1514f1 100644 + transfer_ownership): + """Create and update an entry copied from the + DS to an external storage device. -+ + +- # For "Shares" folder, we need to set the permissions of the newly +- # copied file to 0777, else it will not be accessible by "httpd" +- # service. +- if metadata['mountpoint'] == '/var/www/web1/web': +- fd = os.open(destination_path, os.O_RDONLY) +- os.fchmod(fd, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) +- os.close(fd) + Besides copying the associated file a file for the preview + and one for the metadata are stored in the hidden directory + .Sugar-Metadata. -+ + +- metadata_file_path = os.path.join(metadata_dir_path, file_name + '.metadata') +- fd = os.open(metadata_file_path, os.O_RDONLY) +- os.fchmod(fd, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) +- os.close(fd) + This function handles renames of an entry on the + external device and avoids name collisions. Renames are + handled failsafe. @@ -567,7 +593,7 @@ index 422e947..b1514f1 100644 + if not file_path or not os.path.exists(file_path): + raise ValueError('Entries without a file cannot be copied to ' + 'removable devices') -+ + + if not metadata.get('title'): + metadata['title'] = _('Untitled') + file_name = get_file_name(metadata['title'], metadata['mime_type']) |