You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
only used by CopyTo in each UserData implementation /shrug
uses private void InsertFileRaw
UserFile (i.e. raw under "data"...) methods:
bool HasFile(string uid, string name)
the implementation suggests this should be a "UserDataFile" thing but I'm 95% sure the implementation of this is simply wrong broken and should be using GetUserFilePath instead of GetUserDataFilePath
ok alright so
UserData:
methods related to "files"
methods related to raw "data" files
methods about user info?
string GetUID(string key);
string GetKey(string uid);
string Create(string uid, bool forceNewKey);
void RevokeKey(string key);
int GetRegisteredCount();
int GetAllCount();
string[] GetRegistered();
string[] GetAll();
T[] LoadRegistered<T>() where T : new();
T[] LoadAll<T>() where T : new();
FileSystemUserData:
Basics
Server.Settings.UserDataRoot
, e.g. ./UserData/string UserRoot =>
... = ./UserData/Userstring GlobalPath =>
...= ./UserData/Global.yamlGlobal.yaml
only contains a Yaml-serializedFileSystemUserData.Global
Dictionary<string, string> UIDs
Basic path/file related stuff
Examples for UID
12345
:string GetUserDir(string uid)
=>./UserData/User/12345
static string GetDataFileName(Type type)
=>Celeste.Mod.CelesteNet.Server.BanInfo.yaml
string GetUserDataFilePath(string uid, Type type)
./UserData/User/12345/Celeste.Mod.CelesteNet.Server.BanInfo.yaml
(?)string GetUserDataFilePath(string uid, string name)
=>./UserData/User/12345/name.yaml
string GetUserFilePath(string uid, string name)
=>./UserData/User/12345/data/name
implementations of user info related stuff:
string GetUID(string key)
string GetKey(string uid)
Load<PrivateUserInfo>(uid).Key;
string Create(string uid, bool forceNewKey)
Global
GetKey(uid)
and if no forceNew, just return this key (loading global was pointless then)Save(uid, new PrivateUserInfo { Key = key, KeyFull = keyFull });
Global
back to yamlvoid RevokeKey(string key)
Global
Global
again,Delete<PrivateUserInfo>(uid);
int GetRegisteredCount()
=> LoadRaw<Global>(GlobalPath).UIDs.Count;
int GetAllCount()
=> Directory.GetDirectories(UserRoot).Length;
string[] GetRegistered()
=> LoadRaw<Global>(GlobalPath).UIDs.Values.ToArray();
string[] GetAll()
=> Directory.GetDirectories(UserRoot).Select(name => Path.GetFileName(name)).ToArray();
T[] LoadRegistered<T>()
=> LoadRaw<Global>(GlobalPath).UIDs.Values.Select(uid => Load<T>(uid)).ToArray();
T[] LoadAll<T>()
=> Directory.GetDirectories(UserRoot).Select(dir => LoadRaw<T>(Path.Combine(dir, GetDataFileName(typeof(T))))).ToArray();
void Insert(string uid, string key, string keyFull, bool registered)
Raw (aren't overrides)
T LoadRaw<T>(string path)
=> TryLoadRaw(path, out T value) ? value : value;
bool TryLoadRaw<T>(string path, out T value)
new T()
and return false if path no existvoid SaveRaw<T>(string path, T data)
void DeleteRaw(string path)
void DeleteRawAll(string path)
UserDataFile (i.e. yamls...) methods:
bool TryLoad<T>(string uid, out T value)
void Save<T>(string uid, T value)
=> SaveRaw(GetUserDataFilePath(uid, typeof(T)), value);
void Delete<T>(string uid)
void InsertData(string uid, string name, Type? type, Stream stream)
private void InsertFileRaw
UserFile (i.e. raw under "data"...) methods:
bool HasFile(string uid, string name)
GetUserFilePath
instead ofGetUserDataFilePath
Stream? ReadFile(string uid, string name)
Stream WriteFile(string uid, string name)
void DeleteFile(string uid, string name)
void InsertFile(string uid, string name, Stream stream)
private void InsertFileRaw
other:
private void CheckCleanup(string uid)
void Wipe(string uid)
DeleteRawAll(GetUserDir(uid));
void CopyTo(UserData other)
private void InsertFileRaw(string path, Stream stream)
InsertData
andInsertFile
which are used byCopyTo(UserData)
Observations:
Global.UIDs
and have aPrivateUserInfo
The text was updated successfully, but these errors were encountered: