Skip to content

Commit 3f130bb

Browse files
NainetenNaineten
authored andcommitted
feat: decode OFPA filenames in LFS Locks dialog
- Implement async decoding of OFPA paths in the LFS Locks window. - Reuse OFPAConverters.PathToDisplayName for consistent rendering. - Ensure decoding happens on a background thread to prevent UI freezing. - Fallback to raw paths for files missing locally. This improves usability for UE5 developers by showing human-readable Actor Labels instead of hashed filenames when managing LFS locks.
1 parent b4ed5d8 commit 3f130bb

2 files changed

Lines changed: 47 additions & 1 deletion

File tree

src/ViewModels/LFSLocks.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ public bool IsLoading
2020
private set => SetProperty(ref _isLoading, value);
2121
}
2222

23+
public IReadOnlyDictionary<string, string> DecodedPaths
24+
{
25+
get
26+
{
27+
if (_repo == null || !_repo.Settings.EnableUnrealEngineSupport || !_repo.Settings.EnableOFPADecoding)
28+
return null;
29+
return _decodedPaths;
30+
}
31+
}
32+
2333
public bool ShowOnlyMyLocks
2434
{
2535
get => _showOnlyMyLocks;
@@ -45,9 +55,15 @@ public LFSLocks(Repository repo, string remote)
4555
{
4656
_userName = await new Commands.Config(repo.FullPath).GetAsync("user.name").ConfigureAwait(false);
4757
_cachedLocks = await new Commands.LFS(_repo.FullPath).GetLocksAsync(_remote).ConfigureAwait(false);
58+
Dictionary<string, string> decodedPaths = null;
59+
if (_repo.Settings.EnableUnrealEngineSupport && _repo.Settings.EnableOFPADecoding)
60+
// Precompute decoded names to avoid showing hashed paths in the UI.
61+
decodedPaths = CalculateDecodedPaths(_cachedLocks);
4862

4963
Dispatcher.UIThread.Post(() =>
5064
{
65+
_decodedPaths = decodedPaths;
66+
OnPropertyChanged(nameof(DecodedPaths));
5167
UpdateVisibleLocks();
5268
IsLoading = false;
5369
HasValidUserName = !string.IsNullOrEmpty(_userName);
@@ -121,6 +137,28 @@ private void UpdateVisibleLocks()
121137
VisibleLocks = visible;
122138
}
123139

140+
private Dictionary<string, string> CalculateDecodedPaths(List<Models.LFSLock> locks)
141+
{
142+
if (_repo == null || locks == null || locks.Count == 0)
143+
return null;
144+
145+
var decodedPaths = new Dictionary<string, string>(StringComparer.Ordinal);
146+
foreach (var lfsLock in locks)
147+
{
148+
var path = lfsLock.Path;
149+
if (!Utilities.OFPAParser.IsOFPAFile(path))
150+
continue;
151+
152+
// Decode only local OFPA files; fall back to raw paths when missing.
153+
var fullPath = Native.OS.GetAbsPath(_repo.FullPath, path);
154+
var decoded = Utilities.OFPAParser.Decode(fullPath);
155+
if (decoded.HasValue)
156+
decodedPaths[path] = decoded.Value.LabelValue;
157+
}
158+
159+
return decodedPaths.Count > 0 ? decodedPaths : null;
160+
}
161+
124162
private Repository _repo;
125163
private string _remote;
126164
private bool _isLoading = true;
@@ -129,5 +167,6 @@ private void UpdateVisibleLocks()
129167
private bool _showOnlyMyLocks = false;
130168
private string _userName;
131169
private bool _hasValidUsername;
170+
private Dictionary<string, string> _decodedPaths = null;
132171
}
133172
}

src/Views/LFSLocks.axaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,14 @@
6666
<Grid ColumnDefinitions="26,*,100,32,32">
6767
<Path Grid.Column="0" Width="14" Height="14" Margin="8,0,4,0" Data="{StaticResource Icons.File}"/>
6868
<Border Grid.Column="1" Margin="4,0" ClipToBounds="True">
69-
<TextBlock Text="{Binding Path}" HorizontalAlignment="Left"/>
69+
<TextBlock HorizontalAlignment="Left">
70+
<TextBlock.Text>
71+
<MultiBinding Converter="{x:Static c:OFPAConverters.PathToDisplayName}">
72+
<Binding Path="Path"/>
73+
<Binding Path="$parent[v:LFSLocks].((vm:LFSLocks)DataContext).DecodedPaths"/>
74+
</MultiBinding>
75+
</TextBlock.Text>
76+
</TextBlock>
7077
</Border>
7178
<Border Grid.Column="2" Margin="8,0" ClipToBounds="True">
7279
<TextBlock Text="{Binding Owner.Name}" HorizontalAlignment="Left"/>

0 commit comments

Comments
 (0)