Exemple #1
0
        /// <summary>
        /// DL開始
        /// </summary>
        public ILoadProcess Start(IJobEngine engine, IAccessLocation srcLocation, ICriFileData data)
        {
            //	アクセス先
            //	現在進行系
            if (engine.HasRequest(data.Identifier))
            {
                //	完了するまで待つ
                return(WaitLoadProcess.Wait(m_dlRequestDict, (dict) => dict[data.Identifier]));
            }

            //	保存先
            var dstLocation = m_storage.ToLocation(data.Path);

            //	同時リクエスト対応
            m_dlRequestDict[data.Identifier] = false;

            var job = DoRequest(engine, srcLocation, dstLocation, data);

            return(new LoadProcess <FileInfo>(
                       job,
                       file =>
            {
                if (GetSuccessDL?.Invoke(data, file) ?? false)
                {
                    //	上書き
                    OnInstalled?.Invoke(data);
                    //	リクエスト完了とする
                    m_dlRequestDict[data.Identifier] = true;
                }
            }, onError: code => DoError(code)));
        }
Exemple #2
0
 private bool HasCacheFile(ICriFileData data)
 {
     if (!m_cacheDB.IsSameVersion(data))
     {
         return(false);
     }
     if (IsBreakFile(data.Path, data.Size))
     {
         return(false);
     }
     return(true);
 }
Exemple #3
0
        /// <summary>
        /// 追加か書き込み
        /// </summary>
        private void AddOrReplace(ICriFileData file)
        {
            var data = Find(file.Identifier);

            if (data == null)
            {
                m_list.Add(new Data
                {
                    key  = file.Identifier,
                    path = file.Path,
                    hash = file.Hash
                });
                return;
            }
            data.key  = file.Identifier;
            data.path = file.Path;
            data.hash = file.Hash;
        }
Exemple #4
0
        /// <summary>
        /// 一致判定
        /// </summary>
        public bool IsSameVersion(ICriFileData file)
        {
            var data = Find(file.Identifier);

            if (data == null)
            {
                //	キーが無いなら一致しない
                return(false);
            }

            if (data.hash != file.Hash)
            {
                //	ハッシュが一致したら同じ
                return(false);
            }

            return(true);
        }
Exemple #5
0
        /// <summary>
        /// リクエスト
        /// </summary>
        private ILoadJob <FileInfo> DoRequest(IJobEngine engine, IAccessLocation src, IAccessLocation dst, ICriFileData data)
        {
            var job = WRDL.GetFileDL(data.Identifier, src, dst, data.Size);

            engine.Enqueue(job);

            return(job);
        }
Exemple #6
0
 /// <summary>
 /// 相手側の値で上書き
 /// </summary>
 public void Replace(ICriFileData data)
 {
     AddOrReplace(data);
 }
Exemple #7
0
 public CriFileData(ICriFileData d) : this(d.Identifier, d.Path, d.Hash, d.Size)
 {
 }
Exemple #8
0
 public void OnAfterDeserialize()
 {
     CueSheetName = string.Intern(CueSheetName);
     Acb          = new CriFileData(CueSheetName + "_acb", m_acbPath, AcbHash, AcbSize);
     Awb          = new CriFileData(CueSheetName + "_awb", m_awbPath, AwbHash, AwbSize);
 }