Make Git LFS transfers work
This commit is contained in:
parent
e5f109eddb
commit
a7ff610aa7
|
@ -656,7 +656,7 @@ namespace SparkleShare {
|
|||
public void FinishFetcher (StorageType storage_type)
|
||||
{
|
||||
this.watcher.EnableRaisingEvents = false;
|
||||
this.fetcher.Complete (storage_type);
|
||||
string identifier = this.fetcher.Complete (storage_type);
|
||||
|
||||
string target_folder_path = DetermineFolderPath ();
|
||||
string target_folder_name = Path.GetFileName (target_folder_path);
|
||||
|
@ -683,8 +683,7 @@ namespace SparkleShare {
|
|||
|
||||
string backend = BaseFetcher.GetBackend (this.fetcher.RemoteUrl.ToString ());
|
||||
|
||||
Config.AddFolder (target_folder_name, this.fetcher.Identifier,
|
||||
this.fetcher.RemoteUrl.ToString (), backend);
|
||||
Config.AddFolder (target_folder_name, identifier, this.fetcher.RemoteUrl.ToString (), backend);
|
||||
|
||||
if (storage_type != StorageType.Plain) {
|
||||
Config.SetFolderOptionalAttribute (target_folder_name,
|
||||
|
|
|
@ -67,7 +67,6 @@ namespace Sparkles {
|
|||
public string RequiredFingerprint { get; protected set; }
|
||||
public readonly bool FetchPriorHistory;
|
||||
public string TargetFolder { get; protected set; }
|
||||
public string Identifier;
|
||||
public SparkleFetcherInfo OriginalFetcherInfo;
|
||||
|
||||
|
||||
|
@ -173,22 +172,12 @@ namespace Sparkles {
|
|||
}
|
||||
|
||||
|
||||
public virtual void Complete (StorageType storage_type)
|
||||
public virtual string Complete (StorageType storage_type)
|
||||
{
|
||||
string identifier_path = Path.Combine (TargetFolder, ".sparkleshare");
|
||||
|
||||
if (File.Exists (identifier_path)) {
|
||||
Identifier = File.ReadAllText (identifier_path).Trim ();
|
||||
|
||||
} else {
|
||||
Identifier = CreateIdentifier ();
|
||||
File.WriteAllText (identifier_path, Identifier);
|
||||
|
||||
if (IsFetchedRepoEmpty)
|
||||
CreateInitialChangeSet ();
|
||||
}
|
||||
|
||||
File.SetAttributes (identifier_path, FileAttributes.Hidden);
|
||||
return Path.GetRandomFileName ().SHA256 ();
|
||||
}
|
||||
|
||||
|
||||
|
@ -224,12 +213,6 @@ namespace Sparkles {
|
|||
}
|
||||
|
||||
|
||||
public static string CreateIdentifier ()
|
||||
{
|
||||
return Path.GetRandomFileName ().SHA256 ();
|
||||
}
|
||||
|
||||
|
||||
protected void OnProgressChanged (double percentage, double speed) {
|
||||
ProgressChanged (percentage, speed);
|
||||
}
|
||||
|
|
|
@ -143,7 +143,7 @@ namespace Sparkles {
|
|||
if (!string.IsNullOrEmpty (config_identifier))
|
||||
this.identifier = config_identifier;
|
||||
else
|
||||
this.identifier = BaseFetcher.CreateIdentifier ();
|
||||
this.identifier = Path.GetRandomFileName ().SHA256 ();
|
||||
|
||||
File.WriteAllText (id_path, this.identifier);
|
||||
File.SetAttributes (id_path, FileAttributes.Hidden);
|
||||
|
|
|
@ -128,7 +128,7 @@ namespace Sparkles.Git {
|
|||
git_clone_command += " --depth=1";
|
||||
|
||||
if (storage_type == StorageType.Media)
|
||||
git_clone_command = "lfs " + git_clone_command;
|
||||
git_clone_command = "lfs clone --progress --no-checkout";
|
||||
|
||||
var git_clone = new GitCommand (Configuration.DefaultConfiguration.TmpPath,
|
||||
string.Format ("{0} \"{1}\" \"{2}\"", git_clone_command, RemoteUrl, TargetFolder),
|
||||
|
@ -264,11 +264,14 @@ namespace Sparkles.Git {
|
|||
}
|
||||
|
||||
|
||||
public override void Complete (StorageType selected_storage_type)
|
||||
public override string Complete (StorageType selected_storage_type)
|
||||
{
|
||||
base.Complete (selected_storage_type);
|
||||
string identifier = base.Complete (selected_storage_type);
|
||||
string identifier_path = Path.Combine (TargetFolder, ".sparkleshare");
|
||||
|
||||
if (IsFetchedRepoEmpty) {
|
||||
File.WriteAllText (identifier_path, identifier);
|
||||
|
||||
var git_add = new GitCommand (TargetFolder, "add .sparkleshare");
|
||||
var git_commit = new GitCommand (TargetFolder, "commit --message=\"Initial commit by SparkleShare\"");
|
||||
|
||||
|
@ -293,6 +296,9 @@ namespace Sparkles.Git {
|
|||
}
|
||||
|
||||
} else {
|
||||
if (File.Exists (identifier_path))
|
||||
identifier = File.ReadAllText (identifier_path).Trim ();
|
||||
|
||||
string branch = "HEAD";
|
||||
string prefered_branch = "SparkleShare";
|
||||
|
||||
|
@ -305,9 +311,18 @@ namespace Sparkles.Git {
|
|||
if (git_show_ref.ExitCode == 0)
|
||||
branch = prefered_branch;
|
||||
|
||||
var git_checkout = new GitCommand (TargetFolder, "checkout --quiet --force " + branch);
|
||||
GitCommand git_checkout;
|
||||
|
||||
if (FetchedRepoStorageType == StorageType.Media)
|
||||
git_checkout = new GitCommand (TargetFolder, "lfs checkout");
|
||||
else
|
||||
git_checkout = new GitCommand (TargetFolder, "checkout --quiet --force " + branch);
|
||||
|
||||
git_checkout.StartAndWaitForExit ();
|
||||
}
|
||||
|
||||
File.SetAttributes (identifier_path, FileAttributes.Hidden);
|
||||
return identifier;
|
||||
}
|
||||
|
||||
|
||||
|
@ -359,7 +374,7 @@ namespace Sparkles.Git {
|
|||
string git_attributes_file_path = Path.Combine (TargetFolder, ".git", "info", "attributes");
|
||||
File.WriteAllText (git_attributes_file_path, "* filter=encryption -diff merge=binary");
|
||||
|
||||
// Store the password
|
||||
// Store the password, TODO: 600 permissions
|
||||
string password_file_path = Path.Combine (TargetFolder, ".git", "info", "encryption_password");
|
||||
File.WriteAllText (password_file_path, password.SHA256 (password_salt));
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ namespace Sparkles.Git {
|
|||
string current_revision = CurrentRevision;
|
||||
|
||||
var git = new GitCommand (LocalPath,
|
||||
"ls-remote --heads --exit-code \"" + RemoteUrl + "\" " + this.branch, auth_info);
|
||||
"ls-remote --heads --exit-code origin " + this.branch, auth_info);
|
||||
|
||||
string output = git.StartAndReadStandardOutput ();
|
||||
|
||||
|
@ -216,7 +216,7 @@ namespace Sparkles.Git {
|
|||
git_lfs_push.StartAndWaitForExit ();
|
||||
}
|
||||
|
||||
var git_push = new GitCommand (LocalPath, string.Format ("push --all --progress \"{0}\"", RemoteUrl), auth_info);
|
||||
var git_push = new GitCommand (LocalPath, string.Format ("push --all --progress origin", RemoteUrl), auth_info);
|
||||
git_push.StartInfo.RedirectStandardError = true;
|
||||
git_push.Start ();
|
||||
|
||||
|
@ -288,7 +288,7 @@ namespace Sparkles.Git {
|
|||
|
||||
public override bool SyncDown ()
|
||||
{
|
||||
var git = new GitCommand (LocalPath, "fetch --progress \"" + RemoteUrl + "\" " + branch, auth_info);
|
||||
var git = new GitCommand (LocalPath, "fetch --progress origin " + branch, auth_info);
|
||||
|
||||
git.StartInfo.RedirectStandardError = true;
|
||||
git.Start ();
|
||||
|
|
Loading…
Reference in a new issue