예제 #1
0
        /// <summary>
        /// Загрузить из файла в облаке список ссылок
        /// </summary>
        public void Load()
        {
            Logger.Info($"Loading links from {LinkContainerName}");

            try
            {
                lock (_lockContainer)
                {
                    string filepath = WebDavPath.Combine(WebDavPath.Root, LinkContainerName);
                    var    file     = (File)_cloud.GetItem(filepath, MailRuCloud.ItemType.File, false).Result;

                    if (file != null && file.Size > 3) //some clients put one/two/three-byte file before original file
                    {
                        _itemList = _cloud.DownloadFileAsJson <ItemList>(file);
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Warn("Cannot load links", e);
            }

            if (null == _itemList)
            {
                _itemList = new ItemList();
            }

            foreach (var f in _itemList.Items)
            {
                f.MapTo = WebDavPath.Clean(f.MapTo);
            }
        }