public override void Syncronize(IDirectoryHandler rootDirectoryHandler) { base.Syncronize(rootDirectoryHandler); IDirectoryHandler statsDirectory; if (!rootDirectoryHandler.IsFilePresent("Stats")) { statsDirectory = rootDirectoryHandler.CreateFile( "Stats", "directory", FileHandlerFactoryLocator.UserFactory.RootUser.Id).FileContainer.CastFileHandler<IDirectoryHandler>(); rootDirectoryHandler.SetPermission( null, "Stats", new ID<IUserOrGroup, Guid>[] { FileHandlerFactoryLocator.UserFactory.AnonymousUser.Id }, FilePermissionEnum.Read, false, false); } else statsDirectory = rootDirectoryHandler.OpenFile("Stats").CastFileHandler<IDirectoryHandler>(); if (!statsDirectory.IsFilePresent("CallHomeTracker")) { statsDirectory.CreateFile( "CallHomeTracker", "callhome", FileHandlerFactoryLocator.UserFactory.RootUser.Id); statsDirectory.SetPermission( null, "CallHomeTracker", new ID<IUserOrGroup, Guid>[] { FileHandlerFactoryLocator.UserFactory.AnonymousUser.Id }, FilePermissionEnum.Read, false, false); } }
public virtual void Syncronize(IDirectoryHandler rootDirectoryHandler) { IFileHandler dir; if (rootDirectoryHandler.IsFilePresent("Actions")) { dir = rootDirectoryHandler.OpenFile("Actions").FileHandler; dir.SyncFromLocalDisk("." + Path.DirectorySeparatorChar + "DefaultFiles" + Path.DirectorySeparatorChar + "Actions", false, DateTime.MinValue); } dir = rootDirectoryHandler.OpenFile("Shell").FileHandler; dir.SyncFromLocalDisk("." + Path.DirectorySeparatorChar + "DefaultFiles" + Path.DirectorySeparatorChar + "Shell", false, DateTime.MinValue); dir = rootDirectoryHandler.OpenFile("API").FileHandler; dir.SyncFromLocalDisk("." + Path.DirectorySeparatorChar + "DefaultFiles" + Path.DirectorySeparatorChar + "API", false, DateTime.MinValue); dir = rootDirectoryHandler.OpenFile("Templates").FileHandler; dir.SyncFromLocalDisk("." + Path.DirectorySeparatorChar + "DefaultFiles" + Path.DirectorySeparatorChar + "Templates", false, DateTime.MinValue); dir = rootDirectoryHandler.OpenFile("Tests").FileHandler; dir.SyncFromLocalDisk("." + Path.DirectorySeparatorChar + "DefaultFiles" + Path.DirectorySeparatorChar + "Tests", false, DateTime.MinValue); dir = rootDirectoryHandler.OpenFile("Pages").FileHandler; dir.SyncFromLocalDisk("." + Path.DirectorySeparatorChar + "DefaultFiles" + Path.DirectorySeparatorChar + "Pages", false, DateTime.MinValue); dir = rootDirectoryHandler.OpenFile("Docs").FileHandler; dir.SyncFromLocalDisk("." + Path.DirectorySeparatorChar + "DefaultFiles" + Path.DirectorySeparatorChar + "Docs", false, DateTime.MinValue); dir = rootDirectoryHandler.OpenFile("Classes").FileHandler; dir.SyncFromLocalDisk("." + Path.DirectorySeparatorChar + "DefaultFiles" + Path.DirectorySeparatorChar + "Classes", false, DateTime.MinValue); if (!rootDirectoryHandler.IsFilePresent("Config")) { dir = (IDirectoryHandler)rootDirectoryHandler.CreateFile( "Config", "directory", FileHandlerFactoryLocator.UserFactory.RootUser.Id); rootDirectoryHandler.SetPermission( null, "Config", new ID<IUserOrGroup, Guid>[] { FileHandlerFactoryLocator.UserFactory.Everybody.Id }, ObjectCloud.Interfaces.Security.FilePermissionEnum.Read, false, false); rootDirectoryHandler.SetPermission( null, "Config", new ID<IUserOrGroup, Guid>[] { FileHandlerFactoryLocator.UserFactory.Administrators.Id }, ObjectCloud.Interfaces.Security.FilePermissionEnum.Administer, false, false); } else dir = rootDirectoryHandler.OpenFile("Config").FileHandler; dir.SyncFromLocalDisk("." + Path.DirectorySeparatorChar + "DefaultFiles" + Path.DirectorySeparatorChar + "Config", false, DateTime.MinValue); if (!rootDirectoryHandler.IsFilePresent("DefaultTemplate")) { dir = rootDirectoryHandler.CreateFile( "DefaultTemplate", "directory", null); rootDirectoryHandler.SetPermission( null, "DefaultTemplate", new ID<IUserOrGroup, Guid>[] { FileHandlerFactoryLocator.UserFactory.Everybody.Id }, FilePermissionEnum.Read, true, false); } else dir = rootDirectoryHandler.OpenFile("DefaultTemplate").FileHandler; /*// Only sync if the DefaultTemplate is empty List<IFileContainer> defaultTemplateFiles = new List<IFileContainer>( dir.FileContainer.CastFileHandler<IDirectoryHandler>().Files); if (defaultTemplateFiles.Count == 0) // Because most installations will modify the DefaultTemplate folder, syncing only happens if the folder is // missing. This will prevent minor system upgrades from overwriting custom look and feel. dir.SyncFromLocalDisk("." + Path.DirectorySeparatorChar + "DefaultFiles" + Path.DirectorySeparatorChar + "DefaultTemplate", false);*/ dir.FileContainer.CastFileHandler<IDirectoryHandler>().SyncFromLocalDisk( "." + Path.DirectorySeparatorChar + "DefaultFiles" + Path.DirectorySeparatorChar + "DefaultTemplate", false, true); // Do not syncronize the index file; this is for the user to update. It's just a web component anyway //IFileHandler indexFile = rootDirectoryHandler.OpenFile("index.oc").FileHandler; //indexFile.SyncFromLocalDisk("." + Path.DirectorySeparatorChar + "DefaultFiles" + Path.DirectorySeparatorChar + "index.oc"); DoUpgrades(rootDirectoryHandler); }