public bool ExecuteUpdateCheck(CommandConfiguration configuration, JObject check) { UpdateFile file = new Update.UpdateFile(configuration.Plugins, check); if (File.Exists(file.filepath)) { try { file = ReadUpdateFile(file); bool performUpdate = CompareTimeForUpdate(file); if (performUpdate) { file.FileTimestamp = DateTime.Today; DownloadUpdate(file, check); WriteUpdateFile(file); return true; } } catch (Exception e) { if (e is IOException) { throw new Exception("IOException: " + e.StackTrace); } else if (e is UnauthorizedAccessException) { FileAttributes attr = (new FileInfo(file.filepath)).Attributes; string exception = "UnAuthorizedAccesException: Unable to access file. "; if ((attr & FileAttributes.ReadOnly) > 0) { exception = exception + "File is readonly"; } throw new Exception(exception + " Stacktrace: " + e.StackTrace); } } } else if (!File.Exists(file.filepath) || !File.Exists(file.checkFilePath)) { file.FileTimestamp = DateTime.Today; DownloadUpdate(file, check); createUpdateFile(file); return true; } return false; }
public bool ExecuteUpdateCheck(CommandConfiguration configuration, JObject check) { UpdateFile file = new Update.UpdateFile(configuration.Plugins, check); if (File.Exists(file.filepath)) { try { file = ReadUpdateFile(file); bool performUpdate = CompareTimeForUpdate(file); if (performUpdate) { file.FileTimestamp = DateTime.Today; DownloadUpdate(file, check); WriteUpdateFile(file); return(true); } } catch (Exception e) { if (e is IOException) { throw new Exception("IOException: " + e.StackTrace); } else if (e is UnauthorizedAccessException) { FileAttributes attr = (new FileInfo(file.filepath)).Attributes; string exception = "UnAuthorizedAccesException: Unable to access file. "; if ((attr & FileAttributes.ReadOnly) > 0) { exception = exception + "File is readonly"; } throw new Exception(exception + " Stacktrace: " + e.StackTrace); } } } else if (!File.Exists(file.filepath) || !File.Exists(file.checkFilePath)) { file.FileTimestamp = DateTime.Today; DownloadUpdate(file, check); createUpdateFile(file); return(true); } return(false); }