/// <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))); }
//======================================== // 関数 //======================================== 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); }
/// <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); }
/// <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); }
internal static void Log_WriteLocalBundle(IAccessLocation souce, IAccessLocation dest) { if (!EnableLog) { return; } Log($"Copy BuiltIn Bundle:{souce} -> {dest}"); }
/// <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); }
public override UnityWebRequest CreateRequest(IAccessLocation location) { #if UNITY_2018_1_OR_NEWER return(UnityWebRequestAssetBundle.GetAssetBundle(location.FullPath)); #else return(UnityWebRequest.GetAssetBundle(location.FullPath)); #endif }
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); }
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()}"); }
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()); }
/// <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) )); }
/// <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); }
public override UnityWebRequest CreateRequest(IAccessLocation location) { return(UnityWebRequest.Get(location.FullPath)); }
public abstract UnityWebRequest CreateRequest(IAccessLocation location);
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)); }
public static ILoadJob <AssetBundle> GetAssetBundle(string identifier, IAccessLocation location) { return(new WRDLJob <AssetBundle>(identifier, location, new WRDL.AssetBundleDL())); }
public static ILoadJob <byte[]> GetBinaryFile(string identifier, IAccessLocation location) { return(new WRDLJob <byte[]>(identifier, location, new WRDL.BytesDL())); }
//================================== // 各通信用ジョブの作成 //================================== public static ILoadJob <string> GetTextFile(string identifier, IAccessLocation location) { return(new WRDLJob <string>(identifier, location, new WRDL.TextDL())); }
private void BuildEmpty(IAccessLocation location) { m_runtimeTable = new Dictionary <string, CachedFileData>(); ChipstarLog.Log_InitStorageDB_FirstCreate(location); }
protected override ILoadJob <string> DoCreateTextLoad(IAccessLocation location) { return(WWWDL.GetTextFile(location)); }
protected override ILoadJob <AssetBundle> DoCreateLocalLoad(IAccessLocation location, string hash, uint crc) { return(new LocalFileLoadJob(location, crc)); }
//================================ // 関数 //================================ /// <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 ); }
/// <summary> /// 開始 /// </summary> protected override void DoRun(IAccessLocation location) { Source = AssetBundle.LoadFromFileAsync(location.FullPath, m_crc); }
//=============================== // 関数 //=============================== /// <summary> /// コンストラクタ /// </summary> public LocalFileLoadJob(string identifier, IAccessLocation location, uint crc) : base(identifier, location, new LocalABHandler()) { m_crc = crc; }
public static ResultCode HttpError(IAccessLocation location, long responseCode, string message) { return(new ResultCode(Code.HttpErrorStart + responseCode, ErrorLevel.Error, message + "\n" + location?.FullPath)); }
/// <summary> /// 開始時 /// </summary> protected override void DoRun(IAccessLocation location) { Source = DLHandler.CreateRequest(location); Source.SendWebRequest(); m_option.Start(); }
public FileDL(IAccessLocation local, long contentLength) { m_local = local; m_contentLength = contentLength; }
internal static void Log_Downloader_RequestBuildMap(IAccessLocation location) { Log(string.Format("Get Request : {0}", location.FullPath)); }
protected override ILoadJob <byte[]> DoCreateBytesLoad(IAccessLocation location) { return(WWWDL.GetBinaryFile(location)); }
protected override ILoadJob <Empty> DoCreateFileDL(IAccessLocation location, IAccessLocation local) { return(WWWDL.GetFileDL(location, local)); }