Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAjay Garg <ajay@activitycentral.com>2012-08-29 03:44:13 (GMT)
committer Ajay Garg <ajay@activitycentral.com>2012-08-29 03:44:13 (GMT)
commit3dbe69fe3efbfc77e05cadc6259f8e66fd520855 (patch)
tree2d3bd6152d48fc8930eb46196bba9ff8d23878e8
parent11890d66cf09774862d79213c0de7a4838d62418 (diff)
[Version-4] 1-to-N feature via School-Server.
Changes of version-4 over version-3 : ==================================== a) Fixed the followin workflow bug :: * Open a "Record" activity instance, take a photo, and save. * Ensure that there is a 'preview' in the Journal. * Upload this entry to School Server. * Empty the Journal. * Empty "Documents" (if not already). * From "Shares" menu, download the "Record" entry, each to "Journal", and "Documents". * It is observed that "Journal" has the preview present, but "Documents" DOES NOT have the preview, only the data file. Fixed the above; now the "Documents", and Mounted Drives, also have the Preview. b) Fixed a logical error, in deriving the filename, from metadata URL. This broke only in certain parasitic cases earlier. Now, this should work fine in all cases.
-rw-r--r--rpms/sugar/0130-1-to-N-feature-via-School-Server.patch96
1 files changed, 57 insertions, 39 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 6efa2fc..2c3bda3 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,23 +1,21 @@
-From 4c90d19f1f033e5b5e885d333ad94b3fad9e780a Mon Sep 17 00:00:00 2001
+From ae3bca646e7eece719628b2187c70714280a60cb Mon Sep 17 00:00:00 2001
From: Ajay Garg <ajay@activitycentral.com>
-Date: Tue, 28 Aug 2012 14:51:02 +0530
-Subject: [PATCH] www
+Date: Wed, 29 Aug 2012 09:04:21 +0530
+Subject: [sugar PATCH] 1-to-N-feature-via-School-Server.
Organization: Sugar Labs Foundation
-
-
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 | 331 ++++++++++++++++++++++-----------
- src/jarabe/journal/palettes.py | 202 +++++++++++++++++---
+ src/jarabe/journal/journaltoolbox.py | 44 ++++-
+ src/jarabe/journal/model.py | 350 ++++++++++++++++++++++-----------
+ src/jarabe/journal/palettes.py | 202 ++++++++++++++++---
src/jarabe/journal/volumestoolbar.py | 41 ++---
- src/jarabe/journal/webdavmanager.py | 146 +++++++++------
+ 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, 575 insertions(+), 273 deletions(-)
+ 10 files changed, 588 insertions(+), 279 deletions(-)
diff --git a/src/jarabe/journal/journalactivity.py b/src/jarabe/journal/journalactivity.py
index fc4773d..5f2a734 100644
@@ -154,7 +152,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..6118aaa 100644
+index 422e947..2dc256a 100644
--- a/src/jarabe/journal/model.py
+++ b/src/jarabe/journal/model.py
@@ -43,7 +43,7 @@ from sugar import dispatch
@@ -387,7 +385,7 @@ index 422e947..6118aaa 100644
def write(metadata, file_path='', update_mtime=True, transfer_ownership=True):
-@@ -845,13 +861,69 @@ def write(metadata, file_path='', update_mtime=True, transfer_ownership=True):
+@@ -845,27 +861,97 @@ def write(metadata, file_path='', update_mtime=True, transfer_ownership=True):
object_id = _get_datastore().create(dbus.Dictionary(metadata),
file_path,
transfer_ownership)
@@ -463,7 +461,10 @@ index 422e947..6118aaa 100644
return object_id
-@@ -861,7 +933,11 @@ def _rename_entry_on_external_device(file_path, destination_path,
+
+-def _rename_entry_on_external_device(file_path, destination_path,
+- metadata_dir_path):
++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:
@@ -473,10 +474,27 @@ index 422e947..6118aaa 100644
+ # using the system call "mv".
+ os.system('mv "%s" "%s"' % (file_path, destination_path))
+
++ # In renaming, we want to delete the metadata-, and preview-
++ # files of the current mount-point, and not the destination
++ # mount-point.
++ # But we also need to ensure that the directory of
++ # 'old_file_path' and 'destination_path' are not same.
++ if os.path.dirname(old_file_path) == os.path.dirname(destination_path):
++ return
++
++ from jarabe.journal.journalactivity import get_mount_point
++ source_metadata_dir_path = get_mount_point() + '/.Sugar-Metadata'
++
old_fname = os.path.basename(file_path)
- old_files = [os.path.join(metadata_dir_path,
+- old_files = [os.path.join(metadata_dir_path,
++ old_files = [os.path.join(source_metadata_dir_path,
old_fname + '.metadata'),
-@@ -876,41 +952,31 @@ def _rename_entry_on_external_device(file_path, destination_path,
+- os.path.join(metadata_dir_path,
++ os.path.join(source_metadata_dir_path,
+ old_fname + '.preview')]
+ for ofile in old_files:
+ if os.path.exists(ofile):
+@@ -876,41 +962,31 @@ def _rename_entry_on_external_device(file_path, destination_path,
'for file=%s', ofile, old_fname)
@@ -539,7 +557,7 @@ index 422e947..6118aaa 100644
metadata_dir_path = os.path.join(metadata['mountpoint'],
JOURNAL_METADATA_DIR)
-@@ -939,25 +1005,64 @@ def _write_entry_on_external_device(metadata, file_path):
+@@ -939,26 +1015,62 @@ def _write_entry_on_external_device(metadata, file_path):
os.close(fh)
os.rename(fn, os.path.join(metadata_dir_path, preview_fname))
@@ -551,11 +569,24 @@ index 422e947..6118aaa 100644
else:
- _rename_entry_on_external_device(file_path, destination_path,
- metadata_dir_path)
+-
+- # 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)
+-
+- 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)
+ preview_destination_path = None
+
+ return (metadata_destination_path, preview_destination_path)
-+
-+
+
+
+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,
@@ -566,22 +597,11 @@ index 422e947..6118aaa 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.
@@ -593,7 +613,7 @@ index 422e947..6118aaa 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'])
@@ -607,18 +627,16 @@ index 422e947..6118aaa 100644
+
+ _write_metadata_and_preview_files_and_return_file_paths(metadata,
+ file_name)
-+ metadata_dir_path = os.path.join(metadata['mountpoint'],
-+ JOURNAL_METADATA_DIR)
+
+ if (os.path.dirname(destination_path) == os.path.dirname(file_path)) or \
+ (transfer_ownership == True):
-+ _rename_entry_on_external_device(file_path, destination_path,
-+ metadata_dir_path)
++ _rename_entry_on_external_device(file_path, destination_path)
+ else:
+ shutil.copy(file_path, destination_path)
-
++
object_id = destination_path
created.send(None, object_id=object_id)
+
diff --git a/src/jarabe/journal/palettes.py b/src/jarabe/journal/palettes.py
index 66dcadc..645ed3a 100644
--- a/src/jarabe/journal/palettes.py
@@ -1079,7 +1097,7 @@ index c24475d..e251300 100644
diff --git a/src/jarabe/journal/webdavmanager.py b/src/jarabe/journal/webdavmanager.py
-index 6cd0713..db99504 100644
+index 6cd0713..e99b7aa 100644
--- a/src/jarabe/journal/webdavmanager.py
+++ b/src/jarabe/journal/webdavmanager.py
@@ -1,5 +1,6 @@
@@ -1297,7 +1315,7 @@ index 6cd0713..db99504 100644
- # It is assumed that the metadata-file is small enough to be
- # read in one call to "read".
+ # This will provide us with "a.txt"
-+ basename = sugar_metadata_basename.rstrip('.metadata')
++ basename = sugar_metadata_basename[0:sugar_metadata_basename.index('.metadata')]
downloaded_metadata_file_path = downloaded_metadata_file_dir + '/' + sugar_metadata_basename
- metadata_resource = root_webdav_sugar_metadata._get_resource_by_key(sugar_metadata_url)