Main interface to the contents of the remote file. The file is dowloaded and stored in a local cache file. PutioFileHandle can be used like a read-only file handle to access that cache. Seeking to an offset and reading from there, like a regular file stream, will be identical to reading from the remote file.
Inheritance: IDisposable
Example #1
0
        public void ProcessQueue()
        {
            lock (this.Padlock)
            {
                int counter = 0;
                while (this.Queue.Count > counter)
                {
                    PutioFileHandle h = this.Queue.ElementAt(counter);
                    if (h.PutioFile.Cache.GetNextBufferRange(h.Position) == null)
                    {
                        counter++;
                        continue;
                    }

                    this.Downloader.Download(h);
                    break;
                }

                if (this.Queue.Count == 0)
                {
                    logger.Debug("There are zero handles, stopping download.");
                    this.Downloader.Stop();
                }
            }
        }
Example #2
0
 public void Download(PutioFileHandle h)
 {
     lock (this.Padlock)
     {
         if (this.DLThread != null && this.DLThread.IsAlive)
         {
             if (this.Handle == h)
             {
                 return;
             }
             this.Stop();
             this.Handle = h;
             this.ContinueDownloading = true;
             this.DLThread            = new Thread(DownloadJob);
             this.DLThread.Start();
         }
         else
         {
             this.Handle              = h;
             this.DLThread            = new Thread(DownloadJob);
             this.ContinueDownloading = true;
             this.DLThread.Start();
         }
     }
 }
Example #3
0
 public Boolean UpdatePosition(PutioFileHandle handle)
 {
     lock (this.Padlock)
     {
         this.ProcessQueue();
         return(true);
     }
 }
Example #4
0
 public Boolean Unregister(PutioFileHandle handle)
 {
     lock (this.Padlock)
     {
         if (!this.Queue.Contains(handle))
             return false;
         logger.Debug("UNRegistering handle {0}", handle);
         this.Queue.Remove(handle);
         this.ProcessQueue();
         return true;
     }
 }
Example #5
0
 public Boolean Unregister(PutioFileHandle handle)
 {
     lock (this.Padlock)
     {
         if (!this.Queue.Contains(handle))
         {
             return(false);
         }
         logger.Debug("UNRegistering handle {0}", handle);
         this.Queue.Remove(handle);
         this.ProcessQueue();
         return(true);
     }
 }
Example #6
0
 public Boolean IsValidHandle(PutioFileHandle handle)
 {
     return(this.OpenHandles.ContainsKey(handle.Guid));
 }
Example #7
0
 public void RemoveHandle(PutioFileHandle handle)
 {
     this.OpenHandles.Remove(handle.Guid);
 }
Example #8
0
 public void AddHandle(PutioFileHandle handle)
 {
     this.OpenHandles.Add(handle.Guid, handle);
 }
Example #9
0
 public Boolean UpdatePosition(PutioFileHandle handle)
 {
     lock (this.Padlock)
     {
         this.ProcessQueue();
         return true;
     }
 }
Example #10
0
 public void Download(PutioFileHandle h)
 {
     lock (this.Padlock)
     {
         if (this.DLThread != null && this.DLThread.IsAlive)
         {
             if (this.Handle == h)
                 return;
             this.Stop();
             this.Handle = h;
             this.ContinueDownloading = true;
             this.DLThread = new Thread(DownloadJob);
             this.DLThread.Start();
         }
         else
         {
             this.Handle = h;
             this.DLThread = new Thread(DownloadJob);
             this.ContinueDownloading = true;
             this.DLThread.Start();
         }
     }
 }
Example #11
0
 public void RemoveHandle(PutioFileHandle handle)
 {
     this.OpenHandles.Remove(handle.Guid);
 }
Example #12
0
 public Boolean IsValidHandle(PutioFileHandle handle)
 {
     return this.OpenHandles.ContainsKey(handle.Guid);
 }
Example #13
0
 public void AddHandle(PutioFileHandle handle)
 {
     this.OpenHandles.Add(handle.Guid, handle);
 }