mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-08 18:28:53 +01:00
Refactoring
This commit is contained in:
parent
fabee4a139
commit
3b6c679f04
2 changed files with 20 additions and 19 deletions
|
@ -391,25 +391,6 @@ class File with EquatableMixin {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the path of this file with the DAV part stripped
|
|
||||||
///
|
|
||||||
/// WebDAV file path: remote.php/dav/files/{username}/{strippedPath}
|
|
||||||
String get strippedPath {
|
|
||||||
if (path.contains("remote.php/dav/files")) {
|
|
||||||
final position = path.indexOf("/", "remote.php/dav/files/".length) + 1;
|
|
||||||
if (position == 0) {
|
|
||||||
// root dir path
|
|
||||||
return ".";
|
|
||||||
} else {
|
|
||||||
return path.substring(position);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String get filename => path_util.basename(path);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
get props => [
|
get props => [
|
||||||
path,
|
path,
|
||||||
|
@ -469,6 +450,25 @@ extension FileExtension on File {
|
||||||
bool isOwned(String username) =>
|
bool isOwned(String username) =>
|
||||||
ownerId == null || ownerId?.toLowerCase() == username.toLowerCase();
|
ownerId == null || ownerId?.toLowerCase() == username.toLowerCase();
|
||||||
|
|
||||||
|
/// Return the path of this file with the DAV part stripped
|
||||||
|
///
|
||||||
|
/// WebDAV file path: remote.php/dav/files/{username}/{strippedPath}
|
||||||
|
String get strippedPath {
|
||||||
|
if (path.contains("remote.php/dav/files")) {
|
||||||
|
final position = path.indexOf("/", "remote.php/dav/files/".length) + 1;
|
||||||
|
if (position == 0) {
|
||||||
|
// root dir path
|
||||||
|
return ".";
|
||||||
|
} else {
|
||||||
|
return path.substring(position);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String get filename => path_util.basename(path);
|
||||||
|
|
||||||
static final _log = Logger("entity.file.FileExtension");
|
static final _log = Logger("entity.file.FileExtension");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import 'package:nc_photos/app_localizations.dart';
|
||||||
import 'package:nc_photos/cache_manager_util.dart';
|
import 'package:nc_photos/cache_manager_util.dart';
|
||||||
import 'package:nc_photos/entity/album.dart';
|
import 'package:nc_photos/entity/album.dart';
|
||||||
import 'package:nc_photos/entity/album/provider.dart';
|
import 'package:nc_photos/entity/album/provider.dart';
|
||||||
|
import 'package:nc_photos/entity/file.dart';
|
||||||
import 'package:nc_photos/k.dart' as k;
|
import 'package:nc_photos/k.dart' as k;
|
||||||
import 'package:nc_photos/theme.dart';
|
import 'package:nc_photos/theme.dart';
|
||||||
import 'package:nc_photos/widget/album_grid_item.dart';
|
import 'package:nc_photos/widget/album_grid_item.dart';
|
||||||
|
|
Loading…
Reference in a new issue