← Back to team overview

ubuntu-phone team mailing list archive

Re: Content Hub Questions

 

On Wed, Feb 18, 2015 at 3:13 PM, Robert Schroll <rschroll@xxxxxxxxx> wrote:

> Hi all,
>
> I've been trying, and largely failing, to understand the content hub. But
> I've managed to crystallize my ignorance into questions, so maybe y'all can
> help me out.
>
> I'm starting with a content importer, and I've gotten to the point where I
> can receive the ContentItem from another app.  The item comes with a file
> URL pointing to ~/.cache/<appid>/HubIncoming/<#>/<filename>, which I can
> open.  So:
>
> 1) Is that file permanent, or will the cache be cleaned occasionally?
>

We use the HubIncoming as a cache to allow access to the file when a
ContentStore[1] wasn't set on the transfer request, and will get purged
automatically by the service.  If you specify a ContentStore, the file will
get copied to the location of the store.  For Beru, I'd recommend setting
the ContentStore on the ContentTransfer, to skip the HubIncoming all
together and save it to the file destination automatically.

>
> 2) This file is a hardlink to the original file.  Does that mean both apps
> can modify the file, or do apparmor rules restrict that?  Is there any
> mechanism to delete this hardlink when the original is deleted?
>

I think the link is created read-only, and is only temporary.   The link
will get removed when the transfer is finished.

>
> 3) The content item has a move() method, but whenever I try it, I get a
> console message, "Failed to move content to: <path> falling back to copy".
> Why is this happening?
>

That happens if the it fails to create the hardlink, usually because it
isn't on the same filesystem.  It falls back to a copy in that case, and
still cleans up when it's finished.

>
> 4) Is the argument to move() relative to some directory, or must I use an
> absolute path?  Is there any abbreviation for $HOME? (~ doesn't seem to
> work.)


This argument should be a full path to the directory you want to store the
file in.  The optional second argument is the new file name, if you choose
to rename the file.  If you want to see an example of an app using
ContentItem.move, look at music-app.

>
> 5) The copy I get as a result of move() isn't a hardlink.  Is it supposed
> to be?
>

No, the move function exists to provide a means for QML apps to save a
permanent version of the file in the transfer.

>
> 6) Is there anyway to tell that two imports are actually the same original
> file?   Short of running md5sum on them, I mean.  The filename in
> HubIncoming seems to be the same as the original file.  Is that
> guaranteed?  The filename will rename the same, unless you use move after
> you receive the file.
>
>

1.
https://developer.ubuntu.com/api/qml/sdk-14.10/Ubuntu.Content.ContentStore/

I hope this helps, please let me know how it goes.
Ken




> Thanks,
> Robert
>
>
> --
> Mailing list: https://launchpad.net/~ubuntu-phone
> Post to     : ubuntu-phone@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~ubuntu-phone
> More help   : https://help.launchpad.net/ListHelp
>

Follow ups

References