예제 #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)));
        }
예제 #2
0
        //========================================
        //  関数
        //========================================

        public RuntimeBundleData(IAssetManager manager, IBundleBuildData build, RuntimePlatform platform, AssetBundleConfig config)
        {
            m_manager  = manager;
            m_manifest = build;
            Path       = config.GetRelativePath(platform, m_manifest.Path, m_manifest.Hash, config.Extension);
            Url        = config.GetLocation(platform, m_manifest.Path);
        }
예제 #3
0
        /// <summary>
        /// 書き込み
        /// </summary>
        public bool Write(IAccessLocation location, byte[] contents)
        {
            if (contents == null || contents.Length <= 0)
            {
                return(false);
            }
            var filePath = location.FullPath;
            var dirPath  = Path.GetDirectoryName(filePath);

            if (!Directory.Exists(dirPath))
            {
                Directory.CreateDirectory(dirPath);
            }

            //	既存ファイルの削除
            if (!DeleteOld(filePath))
            {
                return(false);
            }
            //	一時書き込み
            if (!WriteTemp(filePath, contents))
            {
                return(false);
            }
            return(true);
        }
예제 #4
0
        /// <summary>
        /// 初期化
        /// </summary>
        public IEnumerator Initialize(RuntimePlatform platform, AssetBundleConfig config)
        {
            m_saveDirRoot = config.GetSaveStorage(platform);
            m_versionFile = config.GetSaveFile(platform);
            var path = m_versionFile.FullPath;

            ChipstarLog.Log_InitStorageDB(path);

            var isExist = File.Exists(path);

            if (!isExist)
            {
                //	なければ空データ
                BuildEmpty(m_versionFile);
                yield break;
            }
            try
            {
                // あったら読み込んで変換
                var table = m_builder.Read(path);
                m_runtimeTable = table.List
                                 .ToDictionary(
                    c => c.Identifier,
                    c => new CachedFileData(c, m_saveDirRoot)
                    );
            }
            catch (Exception e)
            {
                // 読み込み失敗したのでとりあえず空でつくりなおし
                ChipstarLog.Assert(e.Message);
                BuildEmpty(m_versionFile);
            }
            yield return(null);
        }
예제 #5
0
 internal static void Log_WriteLocalBundle(IAccessLocation souce, IAccessLocation dest)
 {
     if (!EnableLog)
     {
         return;
     }
     Log($"Copy BuiltIn Bundle:{souce} -> {dest}");
 }
예제 #6
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);
        }
예제 #7
0
            public override UnityWebRequest CreateRequest(IAccessLocation location)
            {
#if UNITY_2018_1_OR_NEWER
                return(UnityWebRequestAssetBundle.GetAssetBundle(location.FullPath));
#else
                return(UnityWebRequest.GetAssetBundle(location.FullPath));
#endif
            }
예제 #8
0
            public override UnityWebRequest CreateRequest(IAccessLocation location)
            {
                var req     = UnityWebRequest.Get(location.FullPath);
                var handler = new DownloadHandlerFile(m_local.FullPath);

                handler.removeFileOnAbort = true;
                req.downloadHandler       = handler;
                return(req);
            }
예제 #9
0
 internal static void Log_ReadLocalTable(CriVersionTable cacheDB, IAccessLocation location)
 {
     if (cacheDB == null)
     {
         Assert($"CRI Local Database Is Null :: { location.FullPath }");
         return;
     }
     Log($"Read Cache Info Success:{location.FullPath}");
     Log($"{cacheDB.ToString()}");
 }
예제 #10
0
        private IEnumerator Copy(IAccessLocation source, IAccessLocation dest)
        {
            ChipstarLog.Log_WriteLocalBundle(source, dest);
            if (File.Exists(dest.FullPath))
            {
                ChipstarLog.Log($"Exsists File::{dest}");
                yield break;
            }
            var www     = UnityWebRequest.Get(source.FullPath);
            var handler = new DownloadHandlerFile(dest.FullPath);

            www.downloadHandler = handler;
            yield return(www.SendWebRequest());
        }
예제 #11
0
        /// <summary>
        /// ダウンロード
        /// </summary>
        protected virtual ILoadProcess CreateDowloadJob(IAccessLocation location, IRuntimeBundleData data)
        {
            if (JobEngine.HasRequest(data.Identifier))
            {
                //	リクエスト済みのモノは無視
                return(SkipLoadProcess.Create(location));
            }
            var localPath = StorageDatabase.GetSaveLocation(data);
            var job       = JobCreator.FileDL(JobEngine, data.Identifier, location, localPath, data.FileSize);

            return(new LoadProcess <FileInfo>(
                       AddJob(job),
                       onCompleted: (info) =>
            {
                //	バージョンを保存
                StorageDatabase.Save(data);
            },
                       onError: code => OnError(code)
                       ));
        }
예제 #12
0
        /// <summary>
        /// 単一データ作成
        /// </summary>
        private BundleBuildData CreateBuildData(IAccessLocation file, IBundleFileManifest buildFileData, IReadOnlyDictionary <string, string> table, AssetBundleManifest manifest)
        {
            var identifier   = buildFileData?.Identifier;
            var abName       = buildFileData?.ABName;
            var crc          = FsUtillity.TryGetCrc(file.FullPath);
            var hash         = manifest.TryGetHashString(abName);
            var dependencies = manifest.TryGetDependencies(abName).Select(c => table[c]).ToArray();
            var size         = FsUtillity.TryGetFileSize(file.FullPath);

            var d = new BundleBuildData
            {
                Path         = abName,
                Identifier   = identifier,
                Assets       = buildFileData?.Address,
                Hash         = hash,
                Crc          = crc,
                Dependencies = dependencies,
                FileSize     = size,
                Labels       = buildFileData?.Labels,
            };

            return(d);
        }
예제 #13
0
 public override UnityWebRequest CreateRequest(IAccessLocation location)
 {
     return(UnityWebRequest.Get(location.FullPath));
 }
예제 #14
0
 public abstract UnityWebRequest CreateRequest(IAccessLocation location);
예제 #15
0
 public static ILoadJob <FileInfo> GetFileDL(string identifier, IAccessLocation source, IAccessLocation local, long size)
 {
     return(new WRDLJob <FileInfo>(identifier, source, new WRDL.FileDL(local, size), 10f));
 }
예제 #16
0
 public static ILoadJob <AssetBundle> GetAssetBundle(string identifier, IAccessLocation location)
 {
     return(new WRDLJob <AssetBundle>(identifier, location, new WRDL.AssetBundleDL()));
 }
예제 #17
0
 public static ILoadJob <byte[]> GetBinaryFile(string identifier, IAccessLocation location)
 {
     return(new WRDLJob <byte[]>(identifier, location, new WRDL.BytesDL()));
 }
예제 #18
0
 //==================================
 //  各通信用ジョブの作成
 //==================================
 public static ILoadJob <string> GetTextFile(string identifier, IAccessLocation location)
 {
     return(new WRDLJob <string>(identifier, location, new WRDL.TextDL()));
 }
예제 #19
0
 private void BuildEmpty(IAccessLocation location)
 {
     m_runtimeTable = new Dictionary <string, CachedFileData>();
     ChipstarLog.Log_InitStorageDB_FirstCreate(location);
 }
예제 #20
0
 protected override ILoadJob <string> DoCreateTextLoad(IAccessLocation location)
 {
     return(WWWDL.GetTextFile(location));
 }
예제 #21
0
 protected override ILoadJob <AssetBundle> DoCreateLocalLoad(IAccessLocation location, string hash, uint crc)
 {
     return(new LocalFileLoadJob(location, crc));
 }
예제 #22
0
 //================================
 //  関数
 //================================
 /// <summary>
 ///
 /// </summary>
 public WRDLJob(string identifier, IAccessLocation location, WRDL.WRHandler <TData> handler, float limit = 10f)
     : base(identifier, location, handler)
 {
     m_option = new RetrySystem(3, new TimeOutSystem(limit));
     //m_option = new TimeOutSystem( limit );
 }
예제 #23
0
 /// <summary>
 /// 開始
 /// </summary>
 protected override void DoRun(IAccessLocation location)
 {
     Source = AssetBundle.LoadFromFileAsync(location.FullPath, m_crc);
 }
예제 #24
0
        //===============================
        //	関数
        //===============================

        /// <summary>
        /// コンストラクタ
        /// </summary>
        public LocalFileLoadJob(string identifier, IAccessLocation location, uint crc)
            : base(identifier, location, new LocalABHandler())
        {
            m_crc = crc;
        }
예제 #25
0
 public static ResultCode HttpError(IAccessLocation location, long responseCode, string message)
 {
     return(new ResultCode(Code.HttpErrorStart + responseCode, ErrorLevel.Error, message + "\n" + location?.FullPath));
 }
예제 #26
0
 /// <summary>
 /// 開始時
 /// </summary>
 protected override void DoRun(IAccessLocation location)
 {
     Source = DLHandler.CreateRequest(location);
     Source.SendWebRequest();
     m_option.Start();
 }
예제 #27
0
 public FileDL(IAccessLocation local, long contentLength)
 {
     m_local         = local;
     m_contentLength = contentLength;
 }
예제 #28
0
 internal static void Log_Downloader_RequestBuildMap(IAccessLocation location)
 {
     Log(string.Format("Get Request : {0}", location.FullPath));
 }
예제 #29
0
 protected override ILoadJob <byte[]> DoCreateBytesLoad(IAccessLocation location)
 {
     return(WWWDL.GetBinaryFile(location));
 }
예제 #30
0
 protected override ILoadJob <Empty> DoCreateFileDL(IAccessLocation location, IAccessLocation local)
 {
     return(WWWDL.GetFileDL(location, local));
 }