コード例 #1
0
        async Task DownloadAndSave(EntryData entry, string fullPath, CancellationToken token)
        {
            // Todo: add cancellationToken
            var syncModel = await m_Client.GetSyncModelAsync(new PersistentKey(entry.EntryType, entry.IdInSource), entry.SourceId, entry.Hash);

            token.ThrowIfCancellationRequested();

            if (syncModel != null)
            {
                var directory = Path.GetDirectoryName(fullPath);

                Directory.CreateDirectory(directory);
                await PlayerFile.SaveAsync(syncModel, fullPath);
            }
        }
コード例 #2
0
        async Task <ISyncModel> DownloadAndSave(StreamKey streamKey, string hash, string fullPath)
        {
            var client    = m_Listener.client;
            var syncModel = await client.GetSyncModelAsync(streamKey.key, streamKey.source, hash);

            if (syncModel != null)
            {
                var directory = Path.GetDirectoryName(fullPath);

                Directory.CreateDirectory(directory);
                await PlayerFile.SaveAsync(syncModel, fullPath);
            }

            return(syncModel);
        }
コード例 #3
0
        internal static async Task DownloadAndStore(IPlayerClient client, string sourceId, ManifestEntry entry, SyncManifest newManifest,
                                                    string downloadFolder, DownloadProgress progress)
        {
            Exception exception = null;

            try
            {
                var syncModel = await client.GetSyncModelAsync(sourceId, entry.ModelPath, entry.Hash);

                if (syncModel != null)
                {
                    // Replace model name with local model paths
                    syncModel.Name = entry.ModelPath;
                    SetReferencedSyncModelPath(syncModel, newManifest);

                    var fullPath  = Path.Combine(downloadFolder, entry.ModelPath);
                    var directory = Path.GetDirectoryName(fullPath);

                    await RunFileIOOperation(async() =>
                    {
                        Directory.CreateDirectory(directory);
                        await PlayerFile.SaveAsync(syncModel, fullPath);
                    });
                }
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            if (exception != null)
            {
                progress.errors.Enqueue(new DownloadError(exception, entry));
            }

            progress.ReportCompleted();
        }