Skip to content

Commit

Permalink
Merge #2492 Fix missing CdFileMgr folder errors
Browse files Browse the repository at this point in the history
  • Loading branch information
politas committed Aug 22, 2018
2 parents 86d1f57 + ae0c7ae commit 81a2391
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file.
- [Core] Fix crash on invalid portable or Steam folder (#2506 by: HebaruSan; reviewed: politas)
- [GUI] Fix red X on HideTab (#2501 by: HebaruSan; reviewed: politas)
- [Core] Set default Exception.Message string for ModuleNotFoundKraken (#2493 by: HebaruSan; reviewed: politas)
- [Core] Fix missing CdFileMgr folder errors (#2492 by: HebaruSan; reviewed: politas)

## v1.25.2 (Goddard)

Expand Down
5 changes: 4 additions & 1 deletion Core/ModuleInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public class ModuleInstaller
private static SortedList<string, ModuleInstaller> instances = new SortedList<string, ModuleInstaller>();

private static readonly ILog log = LogManager.GetLogger(typeof(ModuleInstaller));
private static readonly TxFileManager file_transaction = new TxFileManager();

private RegistryManager registry_manager;
private KSP ksp;
Expand Down Expand Up @@ -686,6 +685,8 @@ public static List<InstallableFile> FindInstallableFiles(CkanModule module, stri
/// </summary>
internal static void CopyZipEntry(ZipFile zipfile, ZipEntry entry, string fullPath, bool makeDirs)
{
TxFileManager file_transaction = new TxFileManager();

if (entry.IsDirectory)
{
// Skip if we're not making directories for this install.
Expand Down Expand Up @@ -809,6 +810,8 @@ public void UninstallList(string mod)

private void Uninstall(string modName)
{
TxFileManager file_transaction = new TxFileManager();

using (var transaction = CkanTransaction.CreateTransactionScope())
{
InstalledModule mod = registry_manager.registry.InstalledModule(modName);
Expand Down
5 changes: 4 additions & 1 deletion Core/Net/Net.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class Net
public static string UserAgentString = "Mozilla/4.0 (compatible; CKAN)";

private static readonly ILog log = LogManager.GetLogger(typeof(Net));
private static readonly TxFileManager FileTransaction = new TxFileManager();

public static readonly Dictionary<string, Uri> ThrottledHosts = new Dictionary<string, Uri>()
{
Expand All @@ -46,6 +45,8 @@ public static string Download(Uri url, string filename = null, IUser user = null

public static string Download(string url, string filename = null, IUser user = null)
{
TxFileManager FileTransaction = new TxFileManager();

user = user ?? new NullUser();
user.RaiseMessage("Downloading {0}", url);

Expand Down Expand Up @@ -128,6 +129,8 @@ public class DownloadTarget

public DownloadTarget(Uri url, Uri fallback = null, string filename = null, long size = 0, string mimeType = "")
{
TxFileManager FileTransaction = new TxFileManager();

this.url = url;
this.fallbackUrl = fallback;
this.filename = string.IsNullOrEmpty(filename)
Expand Down
5 changes: 4 additions & 1 deletion Core/Net/NetFileCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public class NetFileCache : IDisposable
private FileSystemWatcher watcher;
private string[] cachedFiles;
private string cachePath;
private static readonly TxFileManager tx_file = new TxFileManager();
private static readonly ILog log = LogManager.GetLogger(typeof (NetFileCache));

public NetFileCache(string _cachePath)
Expand Down Expand Up @@ -291,6 +290,8 @@ public string Store(Uri url, string path, string description = null, bool move =
{
log.DebugFormat("Storing {0}", url);

TxFileManager tx_file = new TxFileManager();

// Make sure we clear our cache entry first.
Remove(url);

Expand Down Expand Up @@ -330,6 +331,8 @@ public string Store(Uri url, string path, string description = null, bool move =
/// </summary>
public bool Remove(Uri url)
{
TxFileManager tx_file = new TxFileManager();

string file = GetCachedFilename(url);

if (file != null)
Expand Down
3 changes: 2 additions & 1 deletion Core/Net/Repo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ namespace CKAN
public static class Repo
{
private static readonly ILog log = LogManager.GetLogger(typeof (Repo));
private static TxFileManager file_transaction = new TxFileManager();

/// <summary>
/// Download and update the local CKAN meta-info.
Expand Down Expand Up @@ -79,6 +78,8 @@ public static int UpdateAllRepositories(RegistryManager registry_manager, KSP ks
/// </summary>
private static List<CkanModule> UpdateRegistry(Uri repo, KSP ksp, IUser user)
{
TxFileManager file_transaction = new TxFileManager();

// Use this opportunity to also update the build mappings... kind of hacky
ServiceLocator.Container.Resolve<IKspBuildMap>().Refresh();

Expand Down
5 changes: 4 additions & 1 deletion Core/Registry/RegistryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public class RegistryManager : IDisposable
private FileStream lockfileStream = null;
private StreamWriter lockfileWriter = null;

private readonly TxFileManager file_transaction = new TxFileManager();

// The only reason we have a KSP field is so we can pass it to the registry
// when deserialising, and *it* only needs it to do registry upgrades.
Expand Down Expand Up @@ -414,6 +413,8 @@ private string SerializeCurrentInstall(bool recommmends = false, bool with_versi

public void Save(bool enforce_consistency = true)
{
TxFileManager file_transaction = new TxFileManager();

log.InfoFormat("Saving CKAN registry at {0}", path);

if (enforce_consistency)
Expand Down Expand Up @@ -463,6 +464,8 @@ public void Save(bool enforce_consistency = true)
/// <param name="with_versions">True to include the mod versions in the file, false to omit them</param>
public void ExportInstalled(string path, bool recommends, bool with_versions)
{
TxFileManager file_transaction = new TxFileManager();

string serialized = SerializeCurrentInstall(recommends, with_versions);
file_transaction.WriteAllText(path, serialized);
}
Expand Down

0 comments on commit 81a2391

Please sign in to comment.