mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-03-28 18:01:35 +01:00
Fix stripped path of nc album and item
This commit is contained in:
parent
705a54762d
commit
7417dd9533
2 changed files with 11 additions and 15 deletions
|
@ -74,18 +74,18 @@ extension NcAlbumExtension on NcAlbum {
|
|||
/// WebDAV file path: remote.php/dav/photos/{userId}/albums/{strippedPath}.
|
||||
/// If this path points to the user's root album path, return "."
|
||||
String get strippedPath {
|
||||
if (!path.startsWith("remote.php/dav/photos/")) {
|
||||
return path;
|
||||
if (!path.startsWith("${api.ApiPhotos.path}/")) {
|
||||
throw ArgumentError("Unsupported path: $path");
|
||||
}
|
||||
var begin = "remote.php/dav/photos/".length;
|
||||
var begin = "${api.ApiPhotos.path}/".length;
|
||||
begin = path.indexOf("/", begin);
|
||||
if (begin == -1) {
|
||||
return path;
|
||||
throw ArgumentError("Unsupported path: $path");
|
||||
}
|
||||
// /albums/{strippedPath}
|
||||
if (path.slice(begin, begin + 7) != "/albums") {
|
||||
return path;
|
||||
}
|
||||
// /albums/
|
||||
begin += 8;
|
||||
final stripped = path.slice(begin);
|
||||
if (stripped.isEmpty) {
|
||||
|
|
|
@ -42,28 +42,24 @@ extension NcAlbumItemExtension on NcAlbumItem {
|
|||
/// If this path points to the user's root album path, return "."
|
||||
String get strippedPath {
|
||||
if (!path.startsWith("${api.ApiPhotos.path}/")) {
|
||||
return path;
|
||||
throw ArgumentError("Unsupported path: $path");
|
||||
}
|
||||
var begin = "${api.ApiPhotos.path}/".length;
|
||||
begin = path.indexOf("/", begin);
|
||||
if (begin == -1) {
|
||||
return path;
|
||||
throw ArgumentError("Unsupported path: $path");
|
||||
}
|
||||
// /albums/{album}/{strippedPath}
|
||||
if (path.slice(begin, begin + 7) != "/albums") {
|
||||
return path;
|
||||
throw ArgumentError("Unsupported path: $path");
|
||||
}
|
||||
// /albums/
|
||||
begin += 8;
|
||||
// {album}/{strippedPath}
|
||||
begin = path.indexOf("/", begin);
|
||||
if (begin == -1) {
|
||||
return path;
|
||||
}
|
||||
final stripped = path.slice(begin + 1);
|
||||
if (stripped.isEmpty) {
|
||||
return ".";
|
||||
} else {
|
||||
return stripped;
|
||||
}
|
||||
return path.slice(begin + 1);
|
||||
}
|
||||
|
||||
bool compareIdentity(NcAlbumItem other) => fileId == other.fileId;
|
||||
|
|
Loading…
Add table
Reference in a new issue