diff --git a/CHANGELOG.md b/CHANGELOG.md index d5bae727..d3915517 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ Visit the package at [pub.dev](https://pub.dev/packages/solidpod). ## 0.10 Complete UI migrations - SecurityKey and Persmissions ++ Delete file by URL + Add fetch resource metadata function [0.9.20 20260131 anushkavid] + Refactor constants, security, and reactivity [0.9.19 20260131 miduo] + Update permission table to list [0.9.18 20260129 jesscmoore] diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 0c8bd8fc..23adda3e 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -25,7 +25,7 @@ dependency_overrides: solidui: git: url: https://github.com/anusii/solidui - ref: jess/190_ui_const_for_perm_history # dev + ref: dev dev_dependencies: flutter_lints: ^6.0.0 diff --git a/lib/src/solid/api/rest_api.dart b/lib/src/solid/api/rest_api.dart index 457c30ea..743cadd4 100644 --- a/lib/src/solid/api/rest_api.dart +++ b/lib/src/solid/api/rest_api.dart @@ -579,7 +579,9 @@ Future getResourceMetadata(String resourceUrl) async { contentType: response.headers[contentType]!, lastModified: dateFormatter.parseUtc(response.headers[lastModified]!), eTag: response.headers[eTag]!, - lastAccessed: dateFormatter.parseUtc(response.headers[lastAccessed]!), + lastAccessed: response.headers.containsKey(lastAccessed) + ? dateFormatter.parseUtc(response.headers[lastAccessed]!) + : null, acceptPatch: response.headers[acceptPatch]!, wacAllow: response.headers[wacAllow]! .replaceAll('user=', '') diff --git a/lib/src/solid/common_func.dart b/lib/src/solid/common_func.dart index 21d1aebb..f9ecd188 100644 --- a/lib/src/solid/common_func.dart +++ b/lib/src/solid/common_func.dart @@ -86,7 +86,7 @@ Future deleteDataFileDialog( actions: [ ElevatedButton( onPressed: () async { - await deleteFile(filePath, contentType: contentType); + await deleteFile(fileUrl: fileUrl, contentType: contentType); if (context.mounted) { Navigator.pop(context); ScaffoldMessenger.of(context).showSnackBar( diff --git a/lib/src/solid/utils/misc.dart b/lib/src/solid/utils/misc.dart index 7b739251..e4dd45f4 100644 --- a/lib/src/solid/utils/misc.dart +++ b/lib/src/solid/utils/misc.dart @@ -553,7 +553,7 @@ Future deleteAclForResource(String resourceUrl) async { } /// Delete a file and its associated resources, after first revoking -/// external access to the file. The file with path [filePath], +/// external access to the file. The file with URL [fileUrl], /// its ACL file, and its encryption key (if exists) will be deleted. /// The permission logs of any recipients to the file, will also be /// updated with a log line recording that permissions have been @@ -562,23 +562,24 @@ Future deleteAclForResource(String resourceUrl) async { /// /// Arguments: /// -/// - [filePath] - path of file to be deleted. Where [filePath] is the -/// app data directory and the filename. +/// - [fileUrl] - URL of file to be deleted. /// - [contentType] - the type of content of the resource. Default: /// [ResourceContentType.turtleText]. /// - [isKey] - flag describing whether the file to be deleted is a /// security key. Use this flag if file is a security key to avoid /// unnecessary operations that are not needed to delete a key. -Future deleteFile( - String filePath, { +Future deleteFile({ + required String fileUrl, ResourceContentType contentType = ResourceContentType.turtleText, bool isKey = false, }) async { - final fileUrl = await getFileUrl(filePath); if (await isFileProtected(fileUrl)) { throw Exception('Delete protected file is not allowed'); } + + final filePath = await extractResourcePathFromUrl(fileUrl); + if (!isKey) { // File to be deleted != key => perform all steps @@ -591,7 +592,11 @@ Future deleteFile( await revokePermissionToRecipients(fileName: filePath); await deleteResource(fileUrl, contentType); - await deleteAclForResource(fileUrl); + + // dc 20260206: ACL file seems to be deleted by the POD server + // when the file is deleted + // + // await deleteAclForResource(fileUrl); await KeyManager.removeIndividualKey(resourcePath: filePath); } else { // File to be deleted == key => perform delete only @@ -607,7 +612,7 @@ Future deleteExternalFile( ResourceContentType contentType = ResourceContentType.turtleText, }) async { await deleteResource(fileUrl, contentType); - await deleteAclForResource(fileUrl); + // await deleteAclForResource(fileUrl); await KeyManager.removeSharedIndividualKey(fileUrl); /// av: Need to add the funtionality to remove the log line from permission diff --git a/lib/src/solid/utils/res_metadata.dart b/lib/src/solid/utils/res_metadata.dart index c9789f79..8b1845c2 100644 --- a/lib/src/solid/utils/res_metadata.dart +++ b/lib/src/solid/utils/res_metadata.dart @@ -41,7 +41,13 @@ class ResourceMetadata { final DateTime lastModified; // The date and time at which the message originate - final DateTime lastAccessed; + // + // dc 20260202: Make the property nullable, as the + // property corresponds to the `date` field of the + // HTTP HEAD response headers. However, `date` may + // not exist if the request is from a web app. + + DateTime? lastAccessed; // A unique string identifying the version of the resource final String eTag;