[Sugar-devel] Journal-like activities (was: Re: [ASLO] Release Read ETexts-19)

Bert Freudenberg bert at freudenbergs.de
Mon Mar 22 11:18:31 EDT 2010


On 22.03.2010, at 15:50, James Simmons wrote:
> 
> I have begun work on a new Activity "Sugar Commander" which will be
> able to copy files from anywhere into the Journal and also update
> Journal metadata, delete Journal entries, etc.
> 
> I want this Activity to work in .82 and up.  In .82 datastore lists
> out files on external media as if they were Journal entries.  The only
> way I've seen to distinguish which is which is to look at the
> "mountpoint" metadata entry for the jobjects.  Unfortunately, while
> they are indeed different for the Journal and for external media I
> can't tell which mountpoint represents which.
> 
> This issue goes away in .84 and later, of course.
> 
> I've been looking at the deprecated Journal Activity to see how it
> does this and I don't see anything that would suggest how it's doing a
> list of just Journal objects.
> 
> If anyone can suggest a way to resolve this I'd be grateful.  The Git
> repository for Sugar Commander is here:
> 
> http://git.sugarlabs.org/projects/sugar-commander
> 
> James Simmons

I just had the same problem working on Scratch. I needed to filter out the USB files when listing Journal entries. I now do that by filtering on the mountpoint.

To figure out the mountpoint of the Journal, I call the datastore's "mounts" method, and take the one with an URI starting with "/home". The USB ones start with "/media":

entries
	self journalMountpoint ifNotNilDo: [:mountpoint | 
		"Filter out USB entries on Sugar 0.82"
		query at: 'mountpoints' put: {mountpoint}].
	^ self datastore find: query with: #('uid' 'title' 'mime_type' 'timestamp')].

journalMountpoint
	"If the datastore mounted multiple volumes (e.g. USB drive), answer the id of the user's Journal, otherwise return nil."
	| mounts uri |
	mounts := [self datastore mounts] ifError: [^ nil].
	mounts size > 1 ifFalse: [^ nil].
	mounts do: [:mount |
		uri := mount at: 'uri' ifAbsent: ['/'].
		(uri beginsWith: '/home')
			ifTrue: [^ mount at: 'id' ifAbsent: [nil]]].
	^ nil

See
http://wiki.sugarlabs.org/go/Development_Team/Low-level_Activity_API#Mount_Points

- Bert -




More information about the Sugar-devel mailing list