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

View file

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

View file

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