Esempio n. 1
0
        /// <summary>
        /// Copy all files in the Data Folder into the Manifest file, optionally making a backup of the current version
        /// <param name="pFileList">List of files to copy</param>
        /// </summary>
        private void _CopyDataFilesIntoManifest(List <string> pFileList)
        {
            if ((pFileList == null) || (pFileList.Count == 0))
            {
                return;
            }

            tbLog.AppendText("Copying files Data folder into Manifest file\n");

            string errorText;
            bool   someFileCopied;

            if (!_addon.CopyFilesFromDataToManifest(pFileList, out someFileCopied, out errorText))
            {
                if (errorText != null)
                {
                    tbLog.AppendText(errorText + "\n");
                }

                if (someFileCopied)
                {
                    _RecreateMirror();
                }
                return;
            }

            // Process ok

            if (!someFileCopied)
            {
                tbLog.AppendText("No file needing to be copied into Manifest file\n");
                return;
            }

            // One or more files have been replaced in the Manifest file
            tbLog.AppendText("Copy of files into Manifest mirror: OK\n");

            if (cbManifestBackup.Checked)
            {
                string backupFile = MiscUtils.CreateManifestBackupFile(_addon.AddonManifest.ManifestFilePath, out errorText);
                if (backupFile == null)
                {
                    tbLog.AppendText($"Creating Manifest backup, ERROR: {errorText}\n");
                    return;
                }
                tbLog.AppendText($"Manifest backup created: {backupFile}\n");
                _mftBackupFiles++;
                pbRestoreBackup.Enabled = true;
            }

            if (!_addon.RefreshManifestFromMirror(out errorText))
            {
                tbLog.AppendText($"Oops! An error has occurred while updating the Manifest file: {errorText}\n");
                return;
            }

            tbLog.AppendText("Refreshing info of files in Manifest file\n");
            _manifestAssetDisplay.SetData(_addon.AddonManifest.AssetList);
        }