Example #1
0
        /// <summary>Returns a stream reading an existing file. </summary>
        public override IndexInput OpenInput(string name)
        {
            CheckDirty();

            if (_inSync)
            {
                try
                {
                    return(CacheDirectory.OpenInput(name));
                }
                catch (FileNotFoundException ex)
                {
                    //if it's not found then we need to re-read from blob so were not in sync
                    LoggingService.Log(new LogEntry(LogLevel.Debug, ex, $"File {name} not found. Will need to resync for {RootFolder}"));

                    SetDirty();
                }
                catch (Exception ex)
                {
                    LoggingService.Log(new LogEntry(LogLevel.Error, ex, $"Could not get local file though we are marked as inSync, reverting to try blob storage; {RootFolder} "));
                }
            }

            if (RemoteDirectory.TryGetBlobFile(name))
            {
                return(_remoteDirectoryIndexInputFactory.GetIndexInput(this, RemoteDirectory, name, LoggingService));
            }
            else
            {
                SetDirty();
                return(CacheDirectory.OpenInput(name));
                //   throw new FileNotFoundException(name, err);
            }
        }