Skip to content

Commit

Permalink
Fix bug with Sampler search
Browse files Browse the repository at this point in the history
  • Loading branch information
RupertAvery committed Dec 4, 2022
1 parent 0fce1a6 commit dad88f0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
12 changes: 10 additions & 2 deletions Diffusion.Database/DataStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,16 @@ public void UpdateImagesByPath(IEnumerable<Image> images)

db.BeginTransaction();

var nonProps = new string[] { nameof(Image.Id) }; /* { "CustomTags", "Rating", "Favorite", "ForDeletion" } */;
var properties = typeof(Image).GetProperties().Where(p => !nonProps.Contains(p.Name)).ToList();
var exclude = new string[]
{
nameof(Image.Id),
nameof(Image.CustomTags),
nameof(Image.Rating),
nameof(Image.Favorite),
nameof(Image.ForDeletion)
};

var properties = typeof(Image).GetProperties().Where(p => !exclude.Contains(p.Name)).ToList();

var query = "UPDATE Image SET ";
var setList = new List<string>();
Expand Down
6 changes: 6 additions & 0 deletions Diffusion.Database/Image.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ public class Image
//public string OtherParameters { get; set; }
//public string Parameters { get; set; }
public DateTime CreatedDate { get; set; }


// These columns shouldn't be overwritten when batch updating
// Consider moving these out?
public string? CustomTags { get; set; }
public int? Rating { get; set; }
public bool Favorite { get; set; }
public bool ForDeletion { get; set; }


public decimal? AestheticScore { get; set; }
public string? HyperNetwork { get; set; }
public decimal? HyperNetworkStrength { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion Diffusion.Database/QueryBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ private static void ParseSampler(ref string prompt, List<KeyValuePair<string, ob
}
}

prompt = prompt.Replace(prompt.Substring(start, current), string.Empty);
prompt = prompt.Replace(prompt.Substring(start, current - start), string.Empty);

var orConditions = new List<KeyValuePair<string, object>>();

Expand Down
3 changes: 0 additions & 3 deletions Diffusion.Toolkit/Pages/Search.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,6 @@ private void ScanInternal(IEnumerable<string> paths, bool updateImages)
HyperNetwork = file.HyperNetwork,
HyperNetworkStrength = file.HyperNetworkStrength,
ClipSkip = file.ClipSkip,
//CustomTags = file.CustomTags,
//OtherParameters = file.OtherParameters,
//Parameters = file.Parameters,
};

if (!string.IsNullOrEmpty(file.HyperNetwork) && !file.HyperNetworkStrength.HasValue)
Expand Down

0 comments on commit dad88f0

Please sign in to comment.