Improve folder path construction logic to handle root and parent paths correctly

This commit is contained in:
Leon Bösche
2026-01-10 01:08:04 +01:00
parent 11436e93c5
commit 1ceb27dea8

View File

@@ -119,9 +119,18 @@ class FileService {
String parentPath,
String folderName,
) async {
// Normalize parent path and construct new folder path
final normalizedParent = parentPath == '/' ? '' : parentPath;
final path = '$normalizedParent/$folderName';
// Construct proper path: /parent/folder or /folder for root
String path;
if (parentPath == '/') {
path = '/$folderName';
} else {
// Ensure parentPath doesn't end with / before appending
final cleanParent = parentPath.endsWith('/')
? parentPath.substring(0, parentPath.length - 1)
: parentPath;
path = '$cleanParent/$folderName';
}
final data = {
'name': folderName,
'path': path,