예제 #1
0
        public void Save(bool enforce_consistency = true)
        {
            TxFileManager file_transaction = new TxFileManager();

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

            if (enforce_consistency)
            {
                // No saving the registry unless it's in a sane state.
                registry.CheckSanity();
            }

            string directoryPath = Path.GetDirectoryName(path);

            if (directoryPath == null)
            {
                log.ErrorFormat("Failed to save registry, invalid path: {0}", path);
                throw new DirectoryNotFoundKraken(path, "Can't find a directory in " + path);
            }

            if (!Directory.Exists(directoryPath))
            {
                Directory.CreateDirectory(directoryPath);
            }

            file_transaction.WriteAllText(path, Serialize());

            string sanitizedName = string.Join("", ksp.Name.Split(Path.GetInvalidFileNameChars()));

            ExportInstalled(
                Path.Combine(directoryPath, $"installed-{sanitizedName}.ckan"),
                false, true
                );
            if (!Directory.Exists(ksp.InstallHistoryDir()))
            {
                Directory.CreateDirectory(ksp.InstallHistoryDir());
            }
            ExportInstalled(
                Path.Combine(
                    ksp.InstallHistoryDir(),
                    $"installed-{sanitizedName}-{DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss")}.ckan"
                    ),
                false, true
                );
        }
예제 #2
0
        public void Save(bool enforce_consistency = true)
        {
            TxFileManager file_transaction = new TxFileManager();

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

            if (enforce_consistency)
            {
                // No saving the registry unless it's in a sane state.
                registry.CheckSanity();
            }

            string directoryPath = Path.GetDirectoryName(path);

            if (directoryPath == null)
            {
                log.ErrorFormat("Failed to save registry, invalid path: {0}", path);
                throw new DirectoryNotFoundKraken(path, "Can't find a directory in " + path);
            }

            if (!Directory.Exists(directoryPath))
            {
                Directory.CreateDirectory(directoryPath);
            }

            file_transaction.WriteAllText(path, Serialize());

            ExportInstalled(
                Path.Combine(directoryPath, LatestInstalledExportFilename()),
                false, true
                );
            if (!Directory.Exists(ksp.InstallHistoryDir()))
            {
                Directory.CreateDirectory(ksp.InstallHistoryDir());
            }
            ExportInstalled(
                Path.Combine(ksp.InstallHistoryDir(), HistoricInstalledExportFilename()),
                false, true
                );
        }