mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 18:14:25 +00:00
CTDB EAC Plugin: timeouts
This commit is contained in:
@@ -382,7 +382,7 @@ namespace CUERipper
|
|||||||
cueSheet.Artist,
|
cueSheet.Artist,
|
||||||
cueSheet.Title);
|
cueSheet.Title);
|
||||||
bool canFix = false;
|
bool canFix = false;
|
||||||
if (cueSheet.CTDB.AccResult == HttpStatusCode.OK && audioSource.ErrorsCount != 0)
|
if (cueSheet.CTDB.QueryExceptionStatus == WebExceptionStatus.Success && audioSource.ErrorsCount != 0)
|
||||||
{
|
{
|
||||||
foreach (DBEntry entry in cueSheet.CTDB.Entries)
|
foreach (DBEntry entry in cueSheet.CTDB.Entries)
|
||||||
if (entry.hasErrors && entry.canRecover)
|
if (entry.hasErrors && entry.canRecover)
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
// backgroundWorker1
|
// backgroundWorker1
|
||||||
//
|
//
|
||||||
this.backgroundWorker1.WorkerReportsProgress = true;
|
this.backgroundWorker1.WorkerReportsProgress = true;
|
||||||
|
this.backgroundWorker1.WorkerSupportsCancellation = true;
|
||||||
this.backgroundWorker1.DoWork += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorker1_DoWork);
|
this.backgroundWorker1.DoWork += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorker1_DoWork);
|
||||||
this.backgroundWorker1.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.backgroundWorker1_RunWorkerCompleted);
|
this.backgroundWorker1.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.backgroundWorker1_RunWorkerCompleted);
|
||||||
this.backgroundWorker1.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.backgroundWorker1_ProgressChanged);
|
this.backgroundWorker1.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.backgroundWorker1_ProgressChanged);
|
||||||
@@ -53,7 +54,6 @@
|
|||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(349, 49);
|
this.ClientSize = new System.Drawing.Size(349, 49);
|
||||||
this.ControlBox = false;
|
|
||||||
this.Controls.Add(this.progressBar1);
|
this.Controls.Add(this.progressBar1);
|
||||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||||
this.MaximizeBox = false;
|
this.MaximizeBox = false;
|
||||||
@@ -63,6 +63,7 @@
|
|||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||||
this.Text = "Contacting CTDB...";
|
this.Text = "Contacting CTDB...";
|
||||||
this.Load += new System.EventHandler(this.FormMetadata_Load);
|
this.Load += new System.EventHandler(this.FormMetadata_Load);
|
||||||
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormSubmitParity_FormClosing);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,5 +69,15 @@ namespace CUETools.CTDB.EACPlugin
|
|||||||
this.progressBar1.Style = e.ProgressPercentage != 0 ? ProgressBarStyle.Continuous : ProgressBarStyle.Marquee;
|
this.progressBar1.Style = e.ProgressPercentage != 0 ? ProgressBarStyle.Continuous : ProgressBarStyle.Marquee;
|
||||||
this.progressBar1.Value = Math.Max(0, Math.Min(100, e.ProgressPercentage));
|
this.progressBar1.Value = Math.Max(0, Math.Min(100, e.ProgressPercentage));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void FormSubmitParity_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
|
{
|
||||||
|
if (this.backgroundWorker1.IsBusy)
|
||||||
|
{
|
||||||
|
e.Cancel = true;
|
||||||
|
this.progressBar1.Style = ProgressBarStyle.Marquee;
|
||||||
|
this.ctdb.CancelRequest();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ namespace MetadataPlugIn
|
|||||||
|
|
||||||
public string GetPluginName()
|
public string GetPluginName()
|
||||||
{
|
{
|
||||||
return "CUETools DB Metadata Plugin V2.1.2";
|
return "CUETools DB Metadata Plugin V2.1.2b";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowOptions()
|
public void ShowOptions()
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ namespace AudioDataPlugIn
|
|||||||
// the plugin and for display in the log file
|
// the plugin and for display in the log file
|
||||||
public string GetAudioTransferPluginName()
|
public string GetAudioTransferPluginName()
|
||||||
{
|
{
|
||||||
return "CUETools DB Plugin V2.1.2";
|
return "CUETools DB Plugin V2.1.2b";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Each plugin should have its own options page.
|
// Each plugin should have its own options page.
|
||||||
@@ -219,7 +219,7 @@ namespace AudioDataPlugIn
|
|||||||
m_data.AlbumArtist,
|
m_data.AlbumArtist,
|
||||||
m_data.AlbumTitle);
|
m_data.AlbumTitle);
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
sw.WriteLine("[CTDB TOCID: {0}] {1}{2}.",
|
sw.WriteLine("[CTDB TOCID: {0}] {1}{2}",
|
||||||
TOC.TOCID,
|
TOC.TOCID,
|
||||||
ctdb.DBStatus ?? "found",
|
ctdb.DBStatus ?? "found",
|
||||||
(ctdb.SubStatus == null) ? "" : (", Submit result: " + ctdb.SubStatus));
|
(ctdb.SubStatus == null) ? "" : (", Submit result: " + ctdb.SubStatus));
|
||||||
@@ -245,7 +245,7 @@ namespace AudioDataPlugIn
|
|||||||
status);
|
status);
|
||||||
}
|
}
|
||||||
bool canFix = false;
|
bool canFix = false;
|
||||||
if (ctdb.AccResult == HttpStatusCode.OK)
|
if (ctdb.QueryExceptionStatus == WebExceptionStatus.Success)
|
||||||
{
|
{
|
||||||
foreach (DBEntry entry in ctdb.Entries)
|
foreach (DBEntry entry in ctdb.Entries)
|
||||||
if (entry.hasErrors && entry.canRecover)
|
if (entry.hasErrors && entry.canRecover)
|
||||||
|
|||||||
@@ -24,15 +24,16 @@ namespace CUETools.CTDB
|
|||||||
|
|
||||||
private CDRepairEncode verify;
|
private CDRepairEncode verify;
|
||||||
private CDImageLayout toc;
|
private CDImageLayout toc;
|
||||||
private HttpStatusCode accResult;
|
|
||||||
private string subResult;
|
private string subResult;
|
||||||
private int length;
|
private int length;
|
||||||
private int total;
|
private int total;
|
||||||
List<DBEntry> entries = new List<DBEntry>();
|
private List<DBEntry> entries = new List<DBEntry>();
|
||||||
List<CTDBResponseMeta> metadata = new List<CTDBResponseMeta>();
|
private List<CTDBResponseMeta> metadata = new List<CTDBResponseMeta>();
|
||||||
DBEntry selectedEntry;
|
private DBEntry selectedEntry;
|
||||||
IWebProxy proxy;
|
private IWebProxy proxy;
|
||||||
HttpUploadHelper uploadHelper;
|
private HttpUploadHelper uploadHelper;
|
||||||
|
private HttpWebRequest currentReq;
|
||||||
|
private int connectTimeout, socketTimeout;
|
||||||
|
|
||||||
public CUEToolsDB(CDImageLayout toc, IWebProxy proxy)
|
public CUEToolsDB(CDImageLayout toc, IWebProxy proxy)
|
||||||
{
|
{
|
||||||
@@ -40,6 +41,19 @@ namespace CUETools.CTDB
|
|||||||
this.length = (int)toc.AudioLength * 588;
|
this.length = (int)toc.AudioLength * 588;
|
||||||
this.proxy = proxy;
|
this.proxy = proxy;
|
||||||
this.uploadHelper = new HttpUploadHelper();
|
this.uploadHelper = new HttpUploadHelper();
|
||||||
|
this.QueryExceptionStatus = WebExceptionStatus.Pending;
|
||||||
|
this.connectTimeout = 15000;
|
||||||
|
this.socketTimeout = 30000;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CancelRequest()
|
||||||
|
{
|
||||||
|
var r = currentReq;
|
||||||
|
// copy link to currentReq, because it can be set to null by other thread.
|
||||||
|
if (r != null)
|
||||||
|
{
|
||||||
|
r.Abort();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ContactDB(string userAgent, string driveName, bool musicbrainz, bool fuzzy)
|
public void ContactDB(string userAgent, string driveName, bool musicbrainz, bool fuzzy)
|
||||||
@@ -55,16 +69,20 @@ namespace CUETools.CTDB
|
|||||||
req.Method = "GET";
|
req.Method = "GET";
|
||||||
req.Proxy = proxy;
|
req.Proxy = proxy;
|
||||||
req.UserAgent = this.userAgent;
|
req.UserAgent = this.userAgent;
|
||||||
|
req.Timeout = connectTimeout;
|
||||||
|
req.ReadWriteTimeout = socketTimeout;
|
||||||
|
|
||||||
if (uploadHelper.onProgress != null)
|
if (uploadHelper.onProgress != null)
|
||||||
uploadHelper.onProgress(this, new UploadProgressEventArgs(req.RequestUri.AbsoluteUri, 0));
|
uploadHelper.onProgress(this, new UploadProgressEventArgs(req.RequestUri.AbsoluteUri, 0));
|
||||||
|
|
||||||
|
currentReq = req;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
|
using (HttpWebResponse resp = (HttpWebResponse)req.GetResponse())
|
||||||
accResult = resp.StatusCode;
|
{
|
||||||
|
this.QueryExceptionStatus = WebExceptionStatus.ProtocolError;
|
||||||
if (accResult == HttpStatusCode.OK)
|
this.QueryResponseStatus = resp.StatusCode;
|
||||||
|
if (this.QueryResponseStatus == HttpStatusCode.OK)
|
||||||
{
|
{
|
||||||
XmlSerializer serializer = new XmlSerializer(typeof(CTDBResponse));
|
XmlSerializer serializer = new XmlSerializer(typeof(CTDBResponse));
|
||||||
this.total = 0;
|
this.total = 0;
|
||||||
@@ -97,15 +115,27 @@ namespace CUETools.CTDB
|
|||||||
metadata.AddRange(ctdbResp.musicbrainz);
|
metadata.AddRange(ctdbResp.musicbrainz);
|
||||||
}
|
}
|
||||||
if (entries.Count == 0)
|
if (entries.Count == 0)
|
||||||
accResult = HttpStatusCode.NotFound;
|
this.QueryResponseStatus = HttpStatusCode.NotFound;
|
||||||
|
else
|
||||||
|
this.QueryExceptionStatus = WebExceptionStatus.Success;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (WebException ex)
|
catch (WebException ex)
|
||||||
{
|
{
|
||||||
if (ex.Status == WebExceptionStatus.ProtocolError)
|
this.QueryExceptionStatus = ex.Status;
|
||||||
accResult = ((HttpWebResponse)ex.Response).StatusCode;
|
this.QueryExceptionMessage = ex.Message;
|
||||||
else
|
if (this.QueryExceptionStatus == WebExceptionStatus.ProtocolError)
|
||||||
accResult = HttpStatusCode.BadRequest;
|
this.QueryResponseStatus = (ex.Response as HttpWebResponse).StatusCode;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
this.QueryExceptionStatus = WebExceptionStatus.UnknownError;
|
||||||
|
this.QueryExceptionMessage = ex.Message;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
currentReq = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,10 +146,14 @@ namespace CUETools.CTDB
|
|||||||
req.Method = "GET";
|
req.Method = "GET";
|
||||||
req.Proxy = proxy;
|
req.Proxy = proxy;
|
||||||
req.UserAgent = this.userAgent;
|
req.UserAgent = this.userAgent;
|
||||||
|
req.Timeout = connectTimeout;
|
||||||
|
req.ReadWriteTimeout = socketTimeout;
|
||||||
|
|
||||||
|
currentReq = req;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
|
using (HttpWebResponse resp = (HttpWebResponse)req.GetResponse())
|
||||||
|
{
|
||||||
entry.httpStatus = resp.StatusCode;
|
entry.httpStatus = resp.StatusCode;
|
||||||
|
|
||||||
if (entry.httpStatus == HttpStatusCode.OK)
|
if (entry.httpStatus == HttpStatusCode.OK)
|
||||||
@@ -145,6 +179,7 @@ namespace CUETools.CTDB
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (WebException ex)
|
catch (WebException ex)
|
||||||
{
|
{
|
||||||
if (ex.Status == WebExceptionStatus.ProtocolError)
|
if (ex.Status == WebExceptionStatus.ProtocolError)
|
||||||
@@ -152,6 +187,10 @@ namespace CUETools.CTDB
|
|||||||
else
|
else
|
||||||
entry.httpStatus = HttpStatusCode.BadRequest;
|
entry.httpStatus = HttpStatusCode.BadRequest;
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
currentReq = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static string uuidInfo = null;
|
static string uuidInfo = null;
|
||||||
@@ -175,7 +214,8 @@ namespace CUETools.CTDB
|
|||||||
|
|
||||||
public string Submit(int confidence, int quality, string artist, string title)
|
public string Submit(int confidence, int quality, string artist, string title)
|
||||||
{
|
{
|
||||||
if (this.AccResult != HttpStatusCode.NotFound && this.AccResult != HttpStatusCode.OK)
|
if (this.QueryExceptionStatus != WebExceptionStatus.Success &&
|
||||||
|
(this.QueryExceptionStatus != WebExceptionStatus.ProtocolError || this.QueryResponseStatus != HttpStatusCode.NotFound))
|
||||||
return this.DBStatus;
|
return this.DBStatus;
|
||||||
DBEntry confirm = null;
|
DBEntry confirm = null;
|
||||||
foreach (DBEntry entry in this.Entries)
|
foreach (DBEntry entry in this.Entries)
|
||||||
@@ -220,6 +260,8 @@ namespace CUETools.CTDB
|
|||||||
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(urlbase + "/submit2.php");
|
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(urlbase + "/submit2.php");
|
||||||
req.Proxy = proxy;
|
req.Proxy = proxy;
|
||||||
req.UserAgent = this.userAgent;
|
req.UserAgent = this.userAgent;
|
||||||
|
req.Timeout = connectTimeout;
|
||||||
|
req.ReadWriteTimeout = socketTimeout;
|
||||||
NameValueCollection form = new NameValueCollection();
|
NameValueCollection form = new NameValueCollection();
|
||||||
if (upload)
|
if (upload)
|
||||||
form.Add("parityfile", "1");
|
form.Add("parityfile", "1");
|
||||||
@@ -240,6 +282,7 @@ namespace CUETools.CTDB
|
|||||||
var ExceptionStatus = WebExceptionStatus.Pending;
|
var ExceptionStatus = WebExceptionStatus.Pending;
|
||||||
string ExceptionMessage = null;
|
string ExceptionMessage = null;
|
||||||
HttpStatusCode ResponseStatus = HttpStatusCode.OK;
|
HttpStatusCode ResponseStatus = HttpStatusCode.OK;
|
||||||
|
currentReq = req;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (HttpWebResponse resp = uploadHelper.Upload(req, files, form))
|
using (HttpWebResponse resp = uploadHelper.Upload(req, files, form))
|
||||||
@@ -263,6 +306,10 @@ namespace CUETools.CTDB
|
|||||||
if (ExceptionStatus == WebExceptionStatus.ProtocolError)
|
if (ExceptionStatus == WebExceptionStatus.ProtocolError)
|
||||||
ResponseStatus = (ex.Response as HttpWebResponse).StatusCode;
|
ResponseStatus = (ex.Response as HttpWebResponse).StatusCode;
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
currentReq = null;
|
||||||
|
}
|
||||||
subResult = ExceptionStatus == WebExceptionStatus.Success ? null :
|
subResult = ExceptionStatus == WebExceptionStatus.Success ? null :
|
||||||
ExceptionStatus != WebExceptionStatus.ProtocolError ? ("database access error: " + (ExceptionMessage ?? ExceptionStatus.ToString())) :
|
ExceptionStatus != WebExceptionStatus.ProtocolError ? ("database access error: " + (ExceptionMessage ?? ExceptionStatus.ToString())) :
|
||||||
ResponseStatus != HttpStatusCode.NotFound ? "database access error: " + ResponseStatus.ToString() :
|
ResponseStatus != HttpStatusCode.NotFound ? "database access error: " + ResponseStatus.ToString() :
|
||||||
@@ -333,7 +380,7 @@ namespace CUETools.CTDB
|
|||||||
|
|
||||||
public void DoVerify()
|
public void DoVerify()
|
||||||
{
|
{
|
||||||
if (this.AccResult != HttpStatusCode.OK)
|
if (this.QueryExceptionStatus != WebExceptionStatus.Success)
|
||||||
return;
|
return;
|
||||||
foreach (DBEntry entry in entries)
|
foreach (DBEntry entry in entries)
|
||||||
{
|
{
|
||||||
@@ -392,11 +439,20 @@ namespace CUETools.CTDB
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public HttpStatusCode AccResult
|
public WebExceptionStatus QueryExceptionStatus { get; private set; }
|
||||||
|
|
||||||
|
public string QueryExceptionMessage { get; private set; }
|
||||||
|
|
||||||
|
public HttpStatusCode QueryResponseStatus { get; private set; }
|
||||||
|
|
||||||
|
public string DBStatus
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return accResult;
|
return QueryExceptionStatus == WebExceptionStatus.Success ? null :
|
||||||
|
QueryExceptionStatus != WebExceptionStatus.ProtocolError ? ("database access error: " + (QueryExceptionMessage ?? QueryExceptionStatus.ToString())) :
|
||||||
|
QueryResponseStatus != HttpStatusCode.NotFound ? "database access error: " + QueryResponseStatus.ToString() :
|
||||||
|
"disk not present in database";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -420,16 +476,6 @@ namespace CUETools.CTDB
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string DBStatus
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return accResult == HttpStatusCode.NotFound ? "disk not present in database" :
|
|
||||||
accResult == HttpStatusCode.OK ? null
|
|
||||||
: accResult.ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public DBEntry SelectedEntry
|
public DBEntry SelectedEntry
|
||||||
{
|
{
|
||||||
set
|
set
|
||||||
|
|||||||
@@ -6314,13 +6314,14 @@ string status = processor.Go();
|
|||||||
return "AccurateRip: confidence too low, will not submit";
|
return "AccurateRip: confidence too low, will not submit";
|
||||||
//if (CTDB.AccResult == HttpStatusCode.OK)
|
//if (CTDB.AccResult == HttpStatusCode.OK)
|
||||||
//return "CUEToolsDB: disc already present in database";
|
//return "CUEToolsDB: disc already present in database";
|
||||||
if (CTDB.AccResult != HttpStatusCode.NotFound && CTDB.AccResult != HttpStatusCode.OK)// && CTDB.AccResult != HttpStatusCode.NoContent)
|
if (CTDB.QueryExceptionStatus != WebExceptionStatus.Success &&
|
||||||
|
(CTDB.QueryExceptionStatus != WebExceptionStatus.ProtocolError || CTDB.QueryResponseStatus != HttpStatusCode.NotFound))
|
||||||
return "CUEToolsDB: " + CTDB.DBStatus;
|
return "CUEToolsDB: " + CTDB.DBStatus;
|
||||||
if (_accurateRipId != null && AccurateRipVerify.CalculateAccurateRipId(_toc) != _accurateRipId)
|
if (_accurateRipId != null && AccurateRipVerify.CalculateAccurateRipId(_toc) != _accurateRipId)
|
||||||
return string.Format("CUEToolsDB: Using preserved id {0}, actual id is {1}", _accurateRipId, AccurateRipVerify.CalculateAccurateRipId(_toc));
|
return string.Format("CUEToolsDB: Using preserved id {0}, actual id is {1}", _accurateRipId, AccurateRipVerify.CalculateAccurateRipId(_toc));
|
||||||
_useCUEToolsDBSibmit = true;
|
_useCUEToolsDBSibmit = true;
|
||||||
string status = Go();
|
string status = Go();
|
||||||
if (CTDB.AccResult == HttpStatusCode.OK)
|
if (CTDB.QueryExceptionStatus == WebExceptionStatus.Success)
|
||||||
foreach (DBEntry entry in CTDB.Entries)
|
foreach (DBEntry entry in CTDB.Entries)
|
||||||
if (entry.toc.TrackOffsets == _toc.TrackOffsets && !entry.hasErrors)
|
if (entry.toc.TrackOffsets == _toc.TrackOffsets && !entry.hasErrors)
|
||||||
return "CUEToolsDB: " + CTDB.Status;
|
return "CUEToolsDB: " + CTDB.Status;
|
||||||
|
|||||||
Reference in New Issue
Block a user