/// -----------------------------------------------------------------------------
 /// <summary>
 /// The DeleteFile method deletes a file.
 /// </summary>
 /// <param name="installFile">The file to delete</param>
 /// <param name="basePath">The basePath to the file</param>
 /// <param name="log">A Logger to log the result</param>
 /// <history>
 ///     [cnurse]	08/03/2007  created
 /// </history>
 /// -----------------------------------------------------------------------------
 public static void DeleteFile(InstallFile installFile, string basePath, Logger log)
 {
     DeleteFile(installFile.FullName, basePath, log);
 }
Beispiel #2
0
        private void ReadZipStream(Stream inputStream, bool isEmbeddedZip)
        {
            Log.StartJob(Util.FILES_Reading);
            var      unzip = new ZipInputStream(inputStream);
            ZipEntry entry = unzip.GetNextEntry();

            while (entry != null)
            {
                if (!entry.IsDirectory)
                {
                    //Add file to list
                    var file = new InstallFile(unzip, entry, this);
                    if (file.Type == InstallFileType.Resources && (file.Name.ToLowerInvariant() == "containers.zip" || file.Name.ToLowerInvariant() == "skins.zip"))
                    {
                        //Temporarily save the TempInstallFolder
                        string tmpInstallFolder = TempInstallFolder;

                        //Create Zip Stream from File
                        var zipStream = new FileStream(file.TempFileName, FileMode.Open, FileAccess.Read);

                        //Set TempInstallFolder
                        TempInstallFolder = Path.Combine(TempInstallFolder, Path.GetFileNameWithoutExtension(file.Name));

                        //Extract files from zip
                        ReadZipStream(zipStream, true);

                        //Restore TempInstallFolder
                        TempInstallFolder = tmpInstallFolder;

                        //Delete zip file
                        var zipFile = new FileInfo(file.TempFileName);
                        zipFile.Delete();
                    }
                    else
                    {
                        Files[file.FullName.ToLower()] = file;
                        if (file.Type == InstallFileType.Manifest && !isEmbeddedZip)
                        {
                            if (ManifestFile == null)
                            {
                                ManifestFile = file;
                            }
                            else
                            {
                                if (file.Extension == "dnn6" && (ManifestFile.Extension == "dnn" || ManifestFile.Extension == "dnn5"))
                                {
                                    ManifestFile = file;
                                }
                                else if (file.Extension == "dnn5" && ManifestFile.Extension == "dnn")
                                {
                                    ManifestFile = file;
                                }
                                else if (file.Extension == ManifestFile.Extension)
                                {
                                    Log.AddFailure((Util.EXCEPTION_MultipleDnn + ManifestFile.Name + " and " + file.Name));
                                }
                            }
                        }
                    }
                    Log.AddInfo(string.Format(Util.FILE_ReadSuccess, file.FullName));
                }
                entry = unzip.GetNextEntry();
            }
            if (ManifestFile == null)
            {
                Log.AddFailure(Util.EXCEPTION_MissingDnn);
            }
            if (Log.Valid)
            {
                Log.EndJob(Util.FILES_ReadingEnd);
            }
            else
            {
                Log.AddFailure(new Exception(Util.EXCEPTION_FileLoad));
                Log.EndJob(Util.FILES_ReadingEnd);
            }

            //Close the Zip Input Stream as we have finished with it
            inputStream.Close();
        }
 private void CreateManifest()
 {
     foreach (string fileName in Regex.Split(txtFiles.Text, Environment.NewLine))
     {
         string name = fileName.Trim();
         if (!string.IsNullOrEmpty(name))
         {
             var file = new InstallFile(name);
             _Writer.AddFile(file);
         }
     }
     foreach (string fileName in Regex.Split(txtAssemblies.Text, Environment.NewLine))
     {
         string name = fileName.Trim();
         if (!string.IsNullOrEmpty(name))
         {
             var file = new InstallFile(name);
             _Writer.AddFile(file);
         }
     }
     txtManifest.Text = _Writer.WriteManifest(false);
 }
Beispiel #4
0
        public static bool IsFileValid(InstallFile file, string packageWhiteList)
        {
            //Check the White List
            FileExtensionWhitelist whiteList = Host.AllowedExtensionWhitelist;

            //Check the White Lists
            string strExtension = file.Extension.ToLowerInvariant();
            if ((strExtension == "dnn" || whiteList.IsAllowedExtension(strExtension) || packageWhiteList.Contains(strExtension) ||
                 (packageWhiteList.Contains("*dataprovider") && strExtension.EndsWith("dataprovider"))))
            {
                //Install File is Valid
                return true;
            }

            return false;
        }
Beispiel #5
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The RestoreFile method restores a file from the backup folder
        /// </summary>
        /// <param name="installFile">The file to restore</param>
        /// <param name="basePath">The basePath to the file</param>
        /// <param name="log">A Logger to log the result</param>
        /// <history>
        /// 	[cnurse]	08/03/2007  created
        /// </history>
        /// -----------------------------------------------------------------------------
        public static void RestoreFile(InstallFile installFile, string basePath, Logger log)
        {
            string fullFileName = Path.Combine(basePath, installFile.FullName);
            string backupFileName = Path.Combine(installFile.BackupPath, installFile.Name + ".config");

            //Copy File back over install file
            FileSystemUtils.CopyFile(backupFileName, fullFileName);

            log.AddInfo(string.Format(FILE_RestoreBackup, installFile.FullName));
        }
Beispiel #6
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The CopyFile method copies a file from the temporary extract location.
        /// </summary>
        /// <param name="installFile">The file to copy</param>
        /// <param name="basePath">The basePath to the file</param>
        /// <param name="log">A Logger to log the result</param>
        /// <history>
        /// 	[cnurse]	08/03/2007  created
        /// </history>
        /// -----------------------------------------------------------------------------
        public static void CopyFile(InstallFile installFile, string basePath, Logger log)
        {
            string filePath = Path.Combine(basePath, installFile.Path);
            string fullFileName = Path.Combine(basePath, installFile.FullName);

            //create the folder if neccessary
            if (!Directory.Exists(filePath))
            {
                log.AddInfo(string.Format(FOLDER_Created, filePath));
                Directory.CreateDirectory(filePath);
            }

            //Copy file from temp location
            RetryableAction.RetryEverySecondFor30Seconds(() => FileSystemUtils.CopyFile(installFile.TempFileName, fullFileName), "Copy file to " + fullFileName);

            log.AddInfo(string.Format(FILE_Created, installFile.FullName));
        }
Beispiel #7
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// The DeleteFile method deletes a file.
 /// </summary>
 /// <param name="installFile">The file to delete</param>
 /// <param name="basePath">The basePath to the file</param>
 /// <param name="log">A Logger to log the result</param>
 /// <history>
 /// 	[cnurse]	08/03/2007  created
 /// </history>
 /// -----------------------------------------------------------------------------
 public static void DeleteFile(InstallFile installFile, string basePath, Logger log)
 {
     DeleteFile(installFile.FullName, basePath, log);
 }
Beispiel #8
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The BackupFile method backs up a file to the backup folder
        /// </summary>
        /// <param name="installFile">The file to backup</param>
        /// <param name="basePath">The basePath to the file</param>
        /// <param name="log">A Logger to log the result</param>
        /// <history>
        /// 	[cnurse]	08/03/2007  created
        /// </history>
        /// -----------------------------------------------------------------------------
        public static void BackupFile(InstallFile installFile, string basePath, Logger log)
        {
            string fullFileName = Path.Combine(basePath, installFile.FullName);
            string backupFileName = Path.Combine(installFile.BackupPath, installFile.Name + ".config");

            //create the backup folder if neccessary
            if (!Directory.Exists(installFile.BackupPath))
            {
                Directory.CreateDirectory(installFile.BackupPath);
            }

            //Copy file to backup location
            RetryableAction.RetryEverySecondFor30Seconds(() => FileSystemUtils.CopyFile(fullFileName, backupFileName), "Backup file " + fullFileName);
            log.AddInfo(string.Format(FILE_CreateBackup, installFile.FullName));
        }
Beispiel #9
0
        private void ReadZipStream(Stream inputStream, bool isEmbeddedZip)
        {
            this.Log.StartJob(Util.FILES_Reading);
            if (inputStream.CanSeek)
            {
                inputStream.Seek(0, SeekOrigin.Begin);
            }

            var      unzip = new ZipInputStream(inputStream);
            ZipEntry entry = unzip.GetNextEntry();

            while (entry != null)
            {
                entry.CheckZipEntry();
                if (!entry.IsDirectory)
                {
                    // Add file to list
                    var file = new InstallFile(unzip, entry, this);
                    if (file.Type == InstallFileType.Resources && (file.Name.Equals("containers.zip", StringComparison.InvariantCultureIgnoreCase) || file.Name.Equals("skins.zip", StringComparison.InvariantCultureIgnoreCase)))
                    {
                        // Temporarily save the TempInstallFolder
                        string tmpInstallFolder = this.TempInstallFolder;

                        // Create Zip Stream from File
                        using (var zipStream = new FileStream(file.TempFileName, FileMode.Open, FileAccess.Read))
                        {
                            // Set TempInstallFolder
                            this.TempInstallFolder = Path.Combine(this.TempInstallFolder, Path.GetFileNameWithoutExtension(file.Name));

                            // Extract files from zip
                            this.ReadZipStream(zipStream, true);
                        }

                        // Restore TempInstallFolder
                        this.TempInstallFolder = tmpInstallFolder;

                        // Delete zip file
                        var zipFile = new FileInfo(file.TempFileName);
                        zipFile.Delete();
                    }
                    else
                    {
                        this.Files[file.FullName.ToLowerInvariant()] = file;
                        if (file.Type == InstallFileType.Manifest && !isEmbeddedZip)
                        {
                            if (this.ManifestFile == null)
                            {
                                this.ManifestFile = file;
                            }
                            else
                            {
                                if (file.Extension == "dnn7" && (this.ManifestFile.Extension == "dnn" || this.ManifestFile.Extension == "dnn5" || this.ManifestFile.Extension == "dnn6"))
                                {
                                    this.ManifestFile = file;
                                }
                                else if (file.Extension == "dnn6" && (this.ManifestFile.Extension == "dnn" || this.ManifestFile.Extension == "dnn5"))
                                {
                                    this.ManifestFile = file;
                                }
                                else if (file.Extension == "dnn5" && this.ManifestFile.Extension == "dnn")
                                {
                                    this.ManifestFile = file;
                                }
                                else if (file.Extension == this.ManifestFile.Extension)
                                {
                                    this.Log.AddFailure(Util.EXCEPTION_MultipleDnn + this.ManifestFile.Name + " and " + file.Name);
                                }
                            }
                        }
                    }

                    this.Log.AddInfo(string.Format(Util.FILE_ReadSuccess, file.FullName));
                }

                entry = unzip.GetNextEntry();
            }

            if (this.ManifestFile == null)
            {
                this.Log.AddFailure(Util.EXCEPTION_MissingDnn);
            }

            if (this.Log.Valid)
            {
                this.Log.EndJob(Util.FILES_ReadingEnd);
            }
            else
            {
                this.Log.AddFailure(new Exception(Util.EXCEPTION_FileLoad));
                this.Log.EndJob(Util.FILES_ReadingEnd);
            }

            // Close the Zip Input Stream as we have finished with it
            inputStream.Close();
        }
Beispiel #10
0
        private void ReadZipStream(Stream inputStream, bool isEmbeddedZip)
        {
            Log.StartJob(Util.FILES_Reading);
            var unzip = new ZipInputStream(inputStream);
            ZipEntry entry = unzip.GetNextEntry();
            while (entry != null)
            {
                if (!entry.IsDirectory)
                {
					//Add file to list
                    var file = new InstallFile(unzip, entry, this);
                    if (file.Type == InstallFileType.Resources && (file.Name.ToLowerInvariant() == "containers.zip" || file.Name.ToLowerInvariant() == "skins.zip"))
                    {
						//Temporarily save the TempInstallFolder
                        string tmpInstallFolder = TempInstallFolder;

                        //Create Zip Stream from File
                        var zipStream = new FileStream(file.TempFileName, FileMode.Open, FileAccess.Read);

                        //Set TempInstallFolder
                        TempInstallFolder = Path.Combine(TempInstallFolder, Path.GetFileNameWithoutExtension(file.Name));

                        //Extract files from zip
                        ReadZipStream(zipStream, true);

                        //Restore TempInstallFolder
                        TempInstallFolder = tmpInstallFolder;

                        //Delete zip file
                        var zipFile = new FileInfo(file.TempFileName);
                        zipFile.Delete();
                    }
                    else
                    {
                        Files[file.FullName.ToLower()] = file;
                        if (file.Type == InstallFileType.Manifest && !isEmbeddedZip)
                        {
                            if (ManifestFile == null)
                            {
                                ManifestFile = file;
                            }
                            else
                            {
                                if (file.Extension == "dnn6" && (ManifestFile.Extension == "dnn" || ManifestFile.Extension == "dnn5"))
                                {
                                   ManifestFile = file; 
                                }
                                else if (file.Extension == "dnn5" && ManifestFile.Extension == "dnn")
                                {
                                    ManifestFile = file;
                                }
                                else if (file.Extension == ManifestFile.Extension)
                                {
                                    Log.AddFailure((Util.EXCEPTION_MultipleDnn + ManifestFile.Name + " and " + file.Name));
                                }
                            }
                        }
                    }
                    Log.AddInfo(string.Format(Util.FILE_ReadSuccess, file.FullName));
                }
                entry = unzip.GetNextEntry();
            }
            if (ManifestFile == null)
            {
                Log.AddFailure(Util.EXCEPTION_MissingDnn);
            }
            if (Log.Valid)
            {
                Log.EndJob(Util.FILES_ReadingEnd);
            }
            else
            {
                Log.AddFailure(new Exception(Util.EXCEPTION_FileLoad));
                Log.EndJob(Util.FILES_ReadingEnd);
            }
			
            //Close the Zip Input Stream as we have finished with it
            inputStream.Close();
        }
Beispiel #11
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// This Constructor creates a new InstallerInfo instance from a PackageInfo object
 /// </summary>
 /// <param name="package">The PackageInfo instance</param>
 /// <param name="sitePath">The physical path to the root of the site</param>
 /// -----------------------------------------------------------------------------
 public InstallerInfo(PackageInfo package, string sitePath)
 {
     Initialize();
     _PhysicalSitePath = sitePath;
     TempInstallFolder = Globals.InstallMapPath + "Temp\\" + Path.GetFileNameWithoutExtension(Path.GetRandomFileName());
     InstallMode = InstallMode.UnInstall;
     ManifestFile = new InstallFile(Path.Combine(TempInstallFolder, package.Name + ".dnn"));
     package.AttachInstallerInfo(this);
 }
Beispiel #12
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// This Constructor creates a new InstallerInfo instance from a string representing
 /// the physical path to the temporary install folder and a string representing 
 /// the physical path to the root of the site
 /// </summary>
 /// <param name="tempFolder">The physical path to the zip file containg the package</param>
 /// <param name="manifest">The manifest filename</param>
 /// <param name="sitePath">The physical path to the root of the site</param>
 /// -----------------------------------------------------------------------------
 public InstallerInfo(string tempFolder, string manifest, string sitePath)
 {
     Initialize();
     TempInstallFolder = tempFolder;
     _PhysicalSitePath = sitePath;
     if (!string.IsNullOrEmpty(manifest))
     {
         ManifestFile = new InstallFile(manifest, this);
     }
 }