Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion lib/src/solid/api/rest_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,9 @@ Future<ResourceMetadata> 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=', '')
Expand Down
2 changes: 1 addition & 1 deletion lib/src/solid/common_func.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Future<void> 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(
Expand Down
21 changes: 13 additions & 8 deletions lib/src/solid/utils/misc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ Future<void> 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
Expand All @@ -562,23 +562,24 @@ Future<void> 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<void> deleteFile(
String filePath, {
Future<void> 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

Expand All @@ -591,7 +592,11 @@ Future<void> 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
Expand All @@ -607,7 +612,7 @@ Future<void> 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
Expand Down
8 changes: 7 additions & 1 deletion lib/src/solid/utils/res_metadata.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down