Example #1
0
        void Save()
        {
            var onlyJournalEntries = journalEntries.Select(p => p.Value);
            var json = JsonConvert.SerializeObject(new PackageData(onlyJournalEntries, Cache));

            fileSystem.EnsureDirectoryExists(Path.GetDirectoryName(journalPath));
            //save to temp file first
            var tempFilePath = $"{journalPath}.temp.{Guid.NewGuid()}.json";

            fileSystem.WriteAllText(tempFilePath, json, Encoding.UTF8);
            fileSystem.OverwriteAndDelete(journalPath, tempFilePath);
        }