repo git: error out when files can't be added to the database. closes #1212

This commit is contained in:
Hylke Bons 2013-03-11 17:02:30 +00:00
parent 69c8116ae1
commit 4dfafdb2a7
3 changed files with 20 additions and 16 deletions

View file

@ -212,13 +212,16 @@ namespace SparkleLib.Git {
public override bool SyncUp () public override bool SyncUp ()
{ {
string message = FormatCommitMessage (); if (!Add ()) {
Error = ErrorStatus.UnreadableFiles;
if (message != null) { return false;
Add ();
Commit (message);
} }
string message = FormatCommitMessage ();
if (message != null)
Commit (message);
if (this.use_git_bin) { if (this.use_git_bin) {
SparkleGitBin git_bin = new SparkleGitBin (LocalPath, "push"); SparkleGitBin git_bin = new SparkleGitBin (LocalPath, "push");
git_bin.StartAndWaitForExit (); git_bin.StartAndWaitForExit ();
@ -414,10 +417,12 @@ namespace SparkleLib.Git {
// Stages the made changes // Stages the made changes
private void Add () private bool Add ()
{ {
SparkleGit git = new SparkleGit (LocalPath, "add --all"); SparkleGit git = new SparkleGit (LocalPath, "add --all");
git.StartAndWaitForExit (); git.StartAndWaitForExit ();
return (git.ExitCode == 0);
} }
@ -478,7 +483,7 @@ namespace SparkleLib.Git {
// Stop when we can't rebase due to locked local files // Stop when we can't rebase due to locked local files
// error: cannot stat 'filename': Permission denied // error: cannot stat 'filename': Permission denied
if (error_output.Contains ("error: cannot stat")) { if (error_output.Contains ("error: cannot stat")) {
Error = ErrorStatus.LockedFiles; Error = ErrorStatus.UnreadableFiles;
SparkleLogger.LogInfo ("Git", Name + " | Error status changed to " + Error); SparkleLogger.LogInfo ("Git", Name + " | Error status changed to " + Error);
git = new SparkleGit (LocalPath, "rebase --abort"); git = new SparkleGit (LocalPath, "rebase --abort");

View file

@ -38,7 +38,7 @@ namespace SparkleLib {
HostIdentityChanged, HostIdentityChanged,
AuthenticationFailed, AuthenticationFailed,
DiskSpaceExceeded, DiskSpaceExceeded,
LockedFiles, UnreadableFiles,
NotFound NotFound
} }
@ -264,6 +264,9 @@ namespace SparkleLib {
do { do {
SyncUpBase (); SyncUpBase ();
if (Error == ErrorStatus.UnreadableFiles)
return;
} while (HasLocalChanges); } while (HasLocalChanges);
} else { } else {
@ -285,11 +288,8 @@ namespace SparkleLib {
{ {
if (Error == ErrorStatus.None || this.is_syncing) if (Error == ErrorStatus.None || this.is_syncing)
return; return;
if (Error == ErrorStatus.LockedFiles) SyncUpBase ();
SyncDownBase ();
else
SyncUpBase ();
} }
@ -466,7 +466,6 @@ namespace SparkleLib {
SparkleLogger.LogInfo (Name, "Syncing due to announcement"); SparkleLogger.LogInfo (Name, "Syncing due to announcement");
SyncDownBase (); SyncDownBase ();
} }
} }

View file

@ -283,8 +283,8 @@ namespace SparkleShare {
} else if (repo.Error == ErrorStatus.DiskSpaceExceeded) { } else if (repo.Error == ErrorStatus.DiskSpaceExceeded) {
folder_errors.Add ("Host is out of disk space"); folder_errors.Add ("Host is out of disk space");
} else if (repo.Error == ErrorStatus.LockedFiles) { } else if (repo.Error == ErrorStatus.UnreadableFiles) {
folder_errors.Add ("Some local files are locked or in use"); folder_errors.Add ("Some local files are unreadable or in use");
} else if (repo.Error == ErrorStatus.NotFound) { } else if (repo.Error == ErrorStatus.NotFound) {
folder_errors.Add ("Project doesn't exist on host"); folder_errors.Add ("Project doesn't exist on host");