integer so unsafe!!! i need HEX!

This commit is contained in:
olcxja 2026-06-05 17:48:20 +02:00
commit 91c526a35f
2 changed files with 20 additions and 6 deletions

View file

@ -28,8 +28,8 @@ public class Utils
}
int hash = id.GetHashCode();
if (hash < 0) hash = -hash; // Or use Math.Abs, but hash < 0 logic avoids OverflowException on int.MinValue
return _userLocksArray[hash % _userLocksArray.Length];
int index = (hash & 0x7FFFFFFF) % _userLocksArray.Length;
return _userLocksArray[index];
}
public static string GetIdFromUsernameWD(string usernameWD)
@ -111,6 +111,10 @@ public class Utils
public static async Task<string> IdFromName(string name)
{
if (name == null || !IsValidUsername(name, out _))
{
return "0";
}
string path = $"{ACCOUNTS_NAME_DIR}/{name.ToLowerInvariant()}";
if (!Fs.Exists(path))
{
@ -288,6 +292,10 @@ public class Utils
public static async Task<byte[]> GetUserPublicStorageEntry(string id, string entry)
{
if (string.IsNullOrEmpty(entry) || entry.Contains("..") || entry.Contains("/") || entry.Contains("\\"))
{
return new byte[] {};
}
string path = $"{ACCOUNTS_DATA_DIR}/{id}/storage/public/{entry}";
if (!Fs.Exists(path))
{

View file

@ -31,8 +31,8 @@ public class Fs
}
int hash = path.GetHashCode();
if (hash < 0) hash = -hash; // Or use Math.Abs, but hash < 0 logic avoids OverflowException on int.MinValue
return _fileLocksArray[hash % _fileLocksArray.Length];
int index = (hash & 0x7FFFFFFF) % _fileLocksArray.Length;
return _fileLocksArray[index];
}
public static void ProcessCacheSpace()
@ -208,7 +208,10 @@ public class Fs
sem1.Wait();
try
{
sem2.Wait();
if (!ReferenceEquals(sem1, sem2))
{
sem2.Wait();
}
try
{
File.Move(path, newPath);
@ -220,7 +223,10 @@ public class Fs
}
finally
{
sem2.Release();
if (!ReferenceEquals(sem1, sem2))
{
sem2.Release();
}
}
}
finally