Skip to content

Commit b2197f9

Browse files
committed
Fix compiler errors
1 parent 7213459 commit b2197f9

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

src/Moryx.Runtime.Kernel/FileSystem/MoryxFileSystem.cs

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,32 @@ public async Task<string> WriteBlob(Stream fileStream, string ownerKey, MoryxFil
9292
tree.Add(metadata);
9393
var treeHash = WriteTree(tree);
9494

95-
// Update owner file
96-
var ownerFilePath = Path.Combine(_ownerFilesDirectory, ownerKey);
97-
if (File.Exists(ownerFilePath))
98-
await File.WriteAllLinesAsync(ownerFilePath, new[] { hash });
99-
else
100-
await File.AppendAllLinesAsync(ownerFilePath, new[] { hash });
95+
await UpdateOwnerFile(hash, ownerFile);
10196

10297
return hash;
10398
}
10499

100+
private static async Task UpdateOwnerFile(string hash, string filePath)
101+
{
102+
if (File.Exists(filePath))
103+
{
104+
#if NETSTANDARD
105+
await Task.Run(() => File.WriteAllLines(filePath, [hash]));
106+
#else
107+
await File.WriteAllLinesAsync(filePath, [hash]);
108+
#endif
109+
}
110+
else
111+
{
112+
#if NETSTANDARD
113+
await Task.Run(() => File.AppendAllLines(filePath, [hash]));
114+
#else
115+
await File.AppendAllLinesAsync(filePath, [hash]);
116+
#endif
117+
}
118+
119+
}
120+
105121
public Stream ReadBlob(string hash)
106122
{
107123
var path = HashPath.FromHash(hash).FilePath(_fsDirectory);
@@ -163,7 +179,7 @@ private bool IsOwner(string hash, string ownerFile)
163179
string line;
164180
while ((line = reader.ReadLine()) != null)
165181
{
166-
if (line.Contains(searchLine))
182+
if (line.Contains(hash))
167183
return true;
168184
}
169185
}

0 commit comments

Comments
 (0)