How to prevent a shared document from downloading more than once?

Gary C Martin gary at garycmartin.com
Mon Mar 16 15:45:11 EDT 2009


On 16 Mar 2009, at 15:29, James Simmons wrote:

> It looks like my last naive question about collaboration started a
> discussion so notable that Walter Bender wrote about it in his blog
> http://walterbender.org/.  Let's see what you can do with this one.
>
> Both my Activities, Read ETexts and View Slides, have document sharing
> code mostly copied from the core Read activity.  Currently this works
> just fine in both Activities, with only one problem.  Suppose someone
> shares a document with me, I receive it successfully, then quit,  
> causing
> the copied document to be saved in my Journal.  Now if the original  
> user
> stops sharing (closes his copy of the Activity) and I resume mine I  
> get
> my stored copy and all is wonderful.  But suppose the original user
> *doesn't* stop sharing.  I resume my copy, see the stored copy on the
> screen, but I *still* download the document my friend is sharing.  I
> don't want to do that.  It wastes bandwidth and time and causes *keep*
> errors when you close the document.
>
> Now the problem is, the sharing code is in the __init__() method,  
> which
> always runs before anything else, and the read_file() method, which  
> runs
> when you resume from the Journal, unfortunately *after* the Activity  
> has
> already decided it needs to download the file.  I need a way for the
> __init__ method to realize that it doesn't need to download the  
> file, or
> some other way to deal with the problem.

Sorry, I'm likely missing something obvious here, but could the  
__init__() check to see if it was resumed from journal, and use that  
as a cue to read the local file? If the file is incomplete/corrupt  
you'd need back out and get the file remotely:

     if handle.object_id == None:
         # Launched from home.
         ... ...
     else:
         # Journal resume, don't download, use local file.
         ... ...

Regards,
--Gary

P.S. This coming from a man who hasn't implemented collaboration in  
any of his activities yet.

> Thanks,
>
> James Simmons
>
>
> _______________________________________________
> Devel mailing list
> Devel at lists.laptop.org
> http://lists.laptop.org/listinfo/devel




More information about the Devel mailing list