コード例 #1
0
        private bool RestoreExtensionFolder(string extensionFolder, string extensionId)
        {
            var source = new DirectoryInfo(_virtualPathProvider.MapPath(_virtualPathProvider.Combine("~", extensionFolder, extensionId)));

            if (source.Exists)
            {
                var    tempPath      = _virtualPathProvider.Combine("~", extensionFolder, "_Backup", extensionId);
                string localTempPath = null;
                for (int i = 0; i < 1000; i++)
                {
                    localTempPath = _virtualPathProvider.MapPath(tempPath) + (i == 0 ? "" : "." + i.ToString());
                    if (!Directory.Exists(localTempPath))
                    {
                        Directory.CreateDirectory(localTempPath);
                        break;
                    }
                    localTempPath = null;
                }

                if (localTempPath == null)
                {
                    throw new OrchardException(T("Backup folder {0} has too many backups subfolder (limit is 1,000)", tempPath));
                }

                var backupFolder = new DirectoryInfo(localTempPath);
                _folderUpdater.Restore(backupFolder, source);
                _notifier.Information(T("Successfully restored local package to local folder \"{0}\"", source));

                return(true);
            }

            return(false);
        }
コード例 #2
0
        private bool RestoreExtensionFolder(string extensionFolder, string extensionId)
        {
            var virtualSource = _virtualPathProvider.Combine("~", extensionFolder, extensionId);
            var source        = new DirectoryInfo(_virtualPathProvider.MapPath(virtualSource));

            if (source.Exists)
            {
                var    tempPath      = _virtualPathProvider.Combine("~/App_Data", "_Backup", extensionFolder, extensionId);
                string localTempPath = null;
                for (int i = 0; i < 1000; i++)
                {
                    localTempPath = _virtualPathProvider.MapPath(tempPath) + (i == 0 ? "" : "." + i.ToString());
                    if (!System.IO.Directory.Exists(localTempPath))
                    {
                        System.IO.Directory.CreateDirectory(localTempPath);
                        break;
                    }
                    localTempPath = null;
                }

                if (localTempPath == null)
                {
                    throw new SmartException(T("Admin.Packaging.TooManyBackups", tempPath));
                }

                var backupFolder = new DirectoryInfo(localTempPath);
                _folderUpdater.Restore(backupFolder, source);
                _notifier.Information(T("Admin.Packaging.RestoreSuccess", virtualSource));

                return(true);
            }

            return(false);
        }