Ejemplo n.º 1
0
        public PryanetRepo(string path, PryanetConfig config)
            : base(path, config)
        {
            PryanetGit git = new PryanetGit (LocalPath, "config core.ignorecase false");
            git.StartAndWaitForExit ();

            // Check if we should use git-bin
            git = new PryanetGit (LocalPath, "config --get filter.bin.clean");
            git.StartAndWaitForExit ();

            this.use_git_bin = (git.ExitCode == 0);

            if (this.use_git_bin)
                ConfigureGitBin ();

            git = new PryanetGit (LocalPath, "config remote.origin.url \"" + RemoteUrl + "\"");
            git.StartAndWaitForExit ();

            string password_file_path = Path.Combine (LocalPath, ".git", "password");

            if (File.Exists (password_file_path))
                this.is_encrypted = true;
        }
Ejemplo n.º 2
0
        public PryanetRepoBase (string path, PryanetConfig config)
        {
            PryanetLogger.LogInfo (path, "Initializing...");

            Status            = SyncStatus.Idle;
            Error             = ErrorStatus.None;
            this.local_config = config;
            LocalPath         = path;
            Name              = Path.GetFileName (LocalPath);
            RemoteUrl         = new Uri (this.local_config.GetUrlForFolder (Name));
            IsBuffering       = false;
            this.identifier   = Identifier;
            ChangeSets        = GetChangeSets ();

			string identifier_file_path = Path.Combine (LocalPath, ".pryanetshare");
			File.SetAttributes (identifier_file_path, FileAttributes.Hidden);

            if (!UseCustomWatcher)
                this.watcher = new PryanetWatcher (LocalPath);

            new Thread (() => CreateListener ()).Start ();

            this.remote_timer.Elapsed += delegate {
                if (this.is_syncing || IsBuffering)
                    return;

                int time_comparison = DateTime.Compare (this.last_poll, DateTime.Now.Subtract (this.poll_interval));

                if (time_comparison < 0) {
                    if (HasUnsyncedChanges && !this.is_syncing)
                        SyncUpBase ();

                    this.last_poll = DateTime.Now;

                    if (HasRemoteChanges && !this.is_syncing)
                        SyncDownBase ();

                    if (this.listener.IsConnected)
                        this.poll_interval = PollInterval.Long;
                }

                // In the unlikely case that we haven't synced up our
                // changes or the server was down, sync up again
                if (HasUnsyncedChanges && !this.is_syncing && Error == ErrorStatus.None)
                    SyncUpBase ();

                if (Status != SyncStatus.Idle && Status != SyncStatus.Error) {
                    Status = SyncStatus.Idle;
                    SyncStatusChanged (Status);
                }
            };
        }
Ejemplo n.º 3
0
 public PryanetControllerBase ()
 {
     string app_data_path = Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData);
     string config_path   = Path.Combine (app_data_path, "pryanetshare");
     
     Config                      = new PryanetConfig (config_path, "config.xml");
     PryanetConfig.DefaultConfig = Config;
     FoldersPath                 = Config.FoldersPath;
 }