mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 09:36:27 +00:00
fileStorage: add file handles
This changes how files work. There is now an open function that translates a path to a file handle (id). Then this handle is used to perform other actions on the file. The file contents are moved to a separate table so that the actual file storage is independent of the database (e.g. in the future, we may use File Access API). We store a hash of the file contents in the metadata file so we can detect file changes without having to compare file contents. We also separate the change and add actions.
This commit is contained in:
@@ -149,3 +149,16 @@ export const testRender = (
|
||||
|
||||
return [result, dispatch];
|
||||
};
|
||||
|
||||
/**
|
||||
* Formats a number as a UUID string.
|
||||
*
|
||||
* The UUID will look like `XXXXXXXX-0000-0000-0000-00000000`.
|
||||
*
|
||||
* This allows for deterministic UUIDs for testing.
|
||||
*
|
||||
* @param id A unique identifier.
|
||||
*/
|
||||
export function uuid(id: number): string {
|
||||
return `${id.toString().padStart(8, '0')}-0000-0000-0000-000000000000`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user