public async Task AddTask(YunFile file, IStorageItem location) { if (file.isdir == 0) { var url = await BaiduYun.GetFileDownloadLink(new[] { file }); if (url == null) { return; } await NewAsyncDownloadTask(url[0], location as IStorageFile); } else { var subfolder = await(location as IStorageFolder).CreateFolderAsync(file.server_filename, CreationCollisionOption.OpenIfExists); var tasks = await HandleFolder(file, subfolder); await Task.WhenAll(tasks); } }
private async Task <List <Task> > HandleFolder(YunFile folder, IStorageFolder location) { var tasks = new List <Task>(); var files = new List <YunFile>(); foreach (var file in await BaiduYun.GetFileList(folder.path)) { if (file.isdir == 1) { var subfolder = await location.CreateFolderAsync(file.server_filename, CreationCollisionOption.OpenIfExists); tasks.AddRange(await HandleFolder(file, subfolder)); } else { files.Add(file); } } tasks.AddRange(await NewAsyncDownloadTasks(files, location)); return(tasks); }
public static async Task <string> GetFileDownloadLink(YunFile file) { var url = await BaiduYun.GetFileDownloadLink(new List <YunFile>() { file }); return(url.FirstOrDefault()); }
public YunFileAdapter(YunFile file) { File = file; Type = GetType(file.isdir, file.path); }