Ejemplo n.º 1
0
        public SmallFileBlockStream OpenReadCachedOnly(FSItem item, Downloader downloader = null)
        {
            CacheEntry entry;
            var        path = Path.Combine(cachePath, item.Id);

            if (!File.Exists(path))
            {
                if (access.TryRemove(item.Id, out entry))
                {
                    TotalSizeDecrease(item.Length);
                }

                return(null);
            }

            if (access.TryGetValue(item.Id, out entry))
            {
                entry.AccessTime = DateTime.UtcNow;
            }
            else
            {
                AddExisting(item);
            }

            Log.Trace("Opened cached: " + item.Id);
            return(SmallFileBlockStream.OpenReadonly(item, path, downloader));
        }
Ejemplo n.º 2
0
        public SmallFileBlockStream OpenReadCachedOnly(FSItem item, Downloader downloader = null)
        {
            var path = GetFilePath(item);

            if (path == null)
            {
                return(null);
            }

            Log.Trace("Opened cached: " + item.Id);
            return(SmallFileBlockStream.OpenReadonly(item, path, downloader));
        }
Ejemplo n.º 3
0
        public SmallFileBlockStream OpenReadWrite(FSItem item)
        {
            var path       = Path.Combine(cachePath, item.Id);
            var downloader = StartDownload(item, path);

            if (access.TryGetValue(item.Id, out CacheEntry entry))
            {
                entry.AccessTime = DateTime.UtcNow;
            }

            Log.Trace("Opened ReadWrite cached: " + item.Id);
            return(SmallFileBlockStream.OpenWriteable(item, path, downloader));
        }