Example #1
0
        public OsPath RemapToFullPath(OsPath sharedFolderPath, DownloadStationSettings settings, string serialNumber)
        {
            var index        = sharedFolderPath.FullPath.IndexOf('/', 1);
            var sharedFolder = index == -1 ? sharedFolderPath : new OsPath(sharedFolderPath.FullPath.Substring(0, index));

            var mapping = _cache.Get($"{serialNumber}:{sharedFolder}", () => GetPhysicalPath(sharedFolder, settings), TimeSpan.FromHours(1));

            var fullPath = mapping.PhysicalPath + (sharedFolderPath - mapping.SharedFolder);

            return(fullPath);
        }
Example #2
0
 public string GetSerialNumber(DownloadStationSettings settings)
 {
     try
     {
         return(_cache.Get(settings.Host, () => GetHashedSerialNumber(settings), TimeSpan.FromMinutes(5)));
     }
     catch (Exception ex)
     {
         _logger.Warn(ex, "Could not get the serial number from Download Station {0}:{1}", settings.Host, settings.Port);
         throw;
     }
 }
Example #3
0
        private SharedFolderMapping GetPhysicalPath(OsPath sharedFolder, DownloadStationSettings settings)
        {
            try
            {
                return(_proxy.GetSharedFolderMapping(sharedFolder.FullPath, settings));
            }
            catch (Exception ex)
            {
                _logger.Warn(ex, "Failed to get shared folder {0} from Disk Station {1}:{2}", sharedFolder, settings.Host, settings.Port);

                throw;
            }
        }
Example #4
0
        private string GetHashedSerialNumber(DownloadStationSettings settings)
        {
            var serialNumber = _proxy.GetSerialNumber(settings);

            return(HashConverter.GetHash(serialNumber).ToHexString());
        }