Exemple #1
0
        protected static void scanDirectory(string path, bool newThread = true)
        {
            logger.Info("Scanning directory {0}", path);

            var t = new ThreadStart(delegate
            {
                var hashingService = HashingService.GetHashingService();

                if (!Directory.Exists(path))
                {
                    return;
                }

                foreach (var file in Directory.GetFiles(path))
                {
                    hashingService.GetHashAsync(file, Priority.Low);
                }

                foreach (var dir in Directory.GetDirectories(path))
                {
                    scanDirectory(dir, false);
                }
            });

            if (newThread)
            {
                new Thread(t).Start();
            }
            else
            {
                t.Invoke();
            }
        }
Exemple #2
0
 static HashingService()
 {
     instance     = new HashingService();
     hashDbFolder = Path.Combine(Program.DatabaseFolder, "Hashes");
     //if (!Directory.Exists(hashDbFolder))
     //{
     //    Directory.CreateDirectory(hashDbFolder);
     //}
 }
 static HashingService()
 {
     instance = new HashingService();
     hashDbFolder = Path.Combine(Program.DatabaseFolder, "Hashes");
     //if (!Directory.Exists(hashDbFolder))
     //{
     //    Directory.CreateDirectory(hashDbFolder);
     //}
 }
Exemple #4
0
        static void Main(string[] args)
        {
            //Display general Info
            printLogo();

            Console.Title = "Wolpertinger Fileserver";
            Console.WriteLine();
            ConsoleHelper.WriteLine(ConsoleColor.Red, " Wolpertinger.FileServer {0}", Assembly.GetExecutingAssembly().GetName().Version.ToString());
            ConsoleHelper.WriteLine(ConsoleColor.Red, " Wolpertinger.Core       {0}", Assembly.GetAssembly(typeof(DefaultConnectionManager)).GetName().Version.ToString());
            Console.WriteLine();

            //Set up XmlSerializer
            XmlSerializer.RegisterType(typeof(ClientInfo), "clientInfo");
            XmlSerializer.RegisterType(typeof(DirectoryObject), "directoryObject");
            XmlSerializer.RegisterType(typeof(FileObject), "fileObject");
            XmlSerializer.RegisterType(typeof(Permission), "permission");
            XmlSerializer.RegisterType(typeof(MountInfo), "mountInfo");
            XmlSerializer.RegisterType(typeof(SnapshotInfo), "snapshotInfo");
            XmlSerializer.RegisterType(typeof(RemoteMethodCall), "remoteMethodCall");
            XmlSerializer.RegisterType(typeof(RemoteMethodResponse), "remoteMethodResponse");
            XmlSerializer.RegisterType(typeof(RemoteError), "remoteError");


            //Set up logger
            LoggerService.SetLogger(new CompositeLogger(new Wolpertinger.Core.ConsoleLogger(), new XmppLogger()));
            logger = LoggerService.GetLogger("Wolpertinger.Fileserver");


            FileObject.HashingService = HashingService.GetHashingService();

            AuthenticationComponent foo = new AuthenticationComponent();


            if (!Directory.Exists(Path.GetDirectoryName(folder)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(folder));
            }

            //Set up AppData directory
            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }

            //Set up databasefolder
            if (!Directory.Exists(DatabaseFolder))
            {
                Directory.CreateDirectory(DatabaseFolder);
            }


            //Initalize ConnectionManager
            //TODO manager.AddProfile(Profile.FileServer);
            //manager.AddComponent(typeof(ClientInfoProvider), typeof(XmppLoggingConfigurator), typeof(FileShare));

            connectionManager = new DefaultConnectionManager();
            //connectionManager.ComponentFactory = new DefaultComponentFactory();
            connectionManager.LoadSettings(folder);
            //connectionManager.Connect();
            connectionManager.AcceptIncomingConnections = true;
            XmppLogger.ConnectionManager = connectionManager;
            XmppLogger.LoadSettings();

            //Load setting specific to this role
            connectionManager.WolpertingerUsername = settingsFile.GetItem <string>("AdminUsername");
            connectionManager.WolpertingerPassword = settingsFile.GetItem <string>("AdminPassword").ToSecureString();


            FileShareServerComponent.Init();

            //Console.WriteLine("Account: " + connectionManager.XmppUsername + "@" + connectionManager.XmppServer);

            Console.ReadLine();
        }