Skip to content
This repository has been archived by the owner on Dec 30, 2019. It is now read-only.

Commit

Permalink
Bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
daramkun committed Nov 15, 2017
1 parent 78f53e1 commit 2488fde
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Daramee.YouTubeUploader/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,15 @@ private void ButtonSetAPIKey_Click ( object sender, RoutedEventArgs e )

private async void ButtonAllUpload_Click ( object sender, RoutedEventArgs e )
{
List<UploadQueueItem> copied = new List<UploadQueueItem> ( uploadQueueListBox.ItemsSource as IEnumerable<UploadQueueItem> );
DataChunkSize chunkSize = ( DataChunkSize ) dataChunkSize.SelectedIndex;
await Task.Run ( new Action ( () =>
{
foreach ( var item in uploadQueueListBox.ItemsSource as ObservableCollection<UploadQueueItem> )
foreach ( var item in copied )
{
if ( item.UploadingStatus == UploadingStatus.Queued || item.UploadingStatus == UploadingStatus.UploadFailed )
{
ThreadPool.QueueUserWorkItem ( async ( i ) => { await UploadItem ( i as UploadQueueItem ); }, item );
ThreadPool.QueueUserWorkItem ( async ( i ) => { await UploadItem ( i as UploadQueueItem, chunkSize ); }, item );
while ( item.UploadingStatus < UploadingStatus.Uploading )
Thread.Sleep ( 1 );
}
Expand Down Expand Up @@ -310,7 +312,7 @@ private void ItemCategoryComboBox_SelectionChanged ( object sender, SelectionCha
private async void ButtonUpload_Click ( object sender, RoutedEventArgs e )
{
var uploadQueueItem = ( ( sender as Button ).DataContext as UploadQueueItem );
await UploadItem ( uploadQueueItem );
await UploadItem ( uploadQueueItem, ( DataChunkSize ) dataChunkSize.SelectedIndex );
}

private void ButtonReInitialize_Click ( object sender, RoutedEventArgs e )
Expand Down Expand Up @@ -573,7 +575,7 @@ private void AddItem ( string filename )
( uploadQueueListBox.ItemsSource as IList<UploadQueueItem> ).Add ( queueItem );
}

private async Task UploadItem ( UploadQueueItem uploadQueueItem )
private async Task UploadItem ( UploadQueueItem uploadQueueItem, DataChunkSize dataChunkSize )
{
if ( uploadQueueItem.Title.Trim ().Length == 0 )
{
Expand All @@ -582,7 +584,7 @@ private async Task UploadItem ( UploadQueueItem uploadQueueItem )
}

string itemName = $"{uploadQueueItem.Title}({Path.GetFileName ( HttpUtility.UrlDecode ( uploadQueueItem.FileName.AbsolutePath ) )})";
switch ( await uploadQueueItem.UploadStart ( ( DataChunkSize ) dataChunkSize.SelectedIndex ) )
switch ( await uploadQueueItem.UploadStart ( dataChunkSize ) )
{
case UploadResult.Succeed:
switch ( uploadQueueItem.UploadingStatus )
Expand Down
1 change: 1 addition & 0 deletions Daramee.YouTubeUploader/Uploader/UploadQueueItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ public async Task<UploadResult> UploadStart ( DataChunkSize dataChunkSize = Data

PC ( nameof ( Progress ) );
PC ( nameof ( UploadingStatus ) );
PC ( nameof ( TotalUploaded ) );
PC ( nameof ( TimeRemaining ) );
};
videoInsertRequest.ResponseReceived += async ( video ) =>
Expand Down

0 comments on commit 2488fde

Please sign in to comment.