mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-03-13 18:58:53 +01:00
Convenient fn to extract filename from File
This commit is contained in:
parent
95cffc0eb3
commit
808c654e75
10 changed files with 13 additions and 19 deletions
|
@ -8,6 +8,7 @@ import 'package:nc_photos/entity/exif.dart';
|
|||
import 'package:nc_photos/or_null.dart';
|
||||
import 'package:nc_photos/string_extension.dart';
|
||||
import 'package:nc_photos/type.dart';
|
||||
import 'package:path/path.dart' as path_util;
|
||||
|
||||
int compareFileDateTimeDescending(File x, File y) {
|
||||
final tmp = y.bestDateTime.compareTo(x.bestDateTime);
|
||||
|
@ -407,6 +408,8 @@ class File with EquatableMixin {
|
|||
}
|
||||
}
|
||||
|
||||
String get filename => path_util.basename(path);
|
||||
|
||||
@override
|
||||
get props => [
|
||||
path,
|
||||
|
|
|
@ -6,7 +6,6 @@ import 'package:nc_photos/exception.dart';
|
|||
import 'package:nc_photos/remote_storage_util.dart' as remote_storage_util;
|
||||
import 'package:nc_photos/use_case/create_dir.dart';
|
||||
import 'package:nc_photos/use_case/ls.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
/// Compatibility helper for v15
|
||||
class CompatV15 {
|
||||
|
@ -45,8 +44,7 @@ class _MigrateAlbumFiles {
|
|||
await CreateDir(fileRepo)(account, intermediateDir);
|
||||
}
|
||||
for (final f in albumFiles) {
|
||||
final fileName = path.basename(f.path);
|
||||
await fileRepo.copy(account, f, "$intermediateDir/$fileName",
|
||||
await fileRepo.copy(account, f, "$intermediateDir/${f.filename}",
|
||||
shouldOverwrite: true);
|
||||
}
|
||||
// rename intermediate
|
||||
|
|
|
@ -3,7 +3,6 @@ import 'package:nc_photos/api/api.dart';
|
|||
import 'package:nc_photos/entity/file.dart';
|
||||
import 'package:nc_photos/mobile/platform.dart'
|
||||
if (dart.library.html) 'package:nc_photos/web/platform.dart' as platform;
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
class DownloadFile {
|
||||
/// Download [file]
|
||||
|
@ -23,7 +22,7 @@ class DownloadFile {
|
|||
"authorization": Api.getAuthorizationHeaderValue(account),
|
||||
},
|
||||
mimeType: file.contentType,
|
||||
filename: path.basename(file.path),
|
||||
filename: file.filename,
|
||||
parentDir: parentDir,
|
||||
shouldNotify: shouldNotify,
|
||||
);
|
||||
|
|
|
@ -2,7 +2,6 @@ import 'package:nc_photos/account.dart';
|
|||
import 'package:nc_photos/entity/file.dart';
|
||||
import 'package:nc_photos/remote_storage_util.dart' as remote_storage_util;
|
||||
import 'package:nc_photos/use_case/move.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
/// Import a shared album from the pending dir to the library
|
||||
class ImportPendingSharedAlbum {
|
||||
|
@ -11,7 +10,7 @@ class ImportPendingSharedAlbum {
|
|||
Future<void> call(Account account, File albumFile) => Move(fileRepo)(
|
||||
account,
|
||||
albumFile,
|
||||
"${remote_storage_util.getRemoteAlbumsDir(account)}/${path.basename(albumFile.path)}",
|
||||
"${remote_storage_util.getRemoteAlbumsDir(account)}/${albumFile.filename}",
|
||||
shouldCreateMissingDir: true,
|
||||
);
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import 'package:nc_photos/entity/file.dart';
|
|||
import 'package:nc_photos/remote_storage_util.dart' as remote_storage_util;
|
||||
import 'package:nc_photos/use_case/list_potential_shared_album.dart';
|
||||
import 'package:nc_photos/use_case/move.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
/// Import new shared albums to the pending dir
|
||||
class ImportPotentialSharedAlbum {
|
||||
|
@ -23,7 +22,7 @@ class ImportPotentialSharedAlbum {
|
|||
await Move(fileRepo)(
|
||||
account,
|
||||
f,
|
||||
"${remote_storage_util.getRemotePendingSharedAlbumsDir(account)}/${path.basename(f.path)}",
|
||||
"${remote_storage_util.getRemotePendingSharedAlbumsDir(account)}/${f.filename}",
|
||||
shouldCreateMissingDir: true,
|
||||
);
|
||||
products.add(album);
|
||||
|
|
|
@ -3,7 +3,6 @@ import 'package:nc_photos/account.dart';
|
|||
import 'package:nc_photos/api/api_util.dart' as api_util;
|
||||
import 'package:nc_photos/entity/file.dart';
|
||||
import 'package:nc_photos/use_case/ls.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
/// List all shared files that are potentially albums
|
||||
///
|
||||
|
@ -28,7 +27,7 @@ class ListPotentialSharedAlbum {
|
|||
|
||||
bool _checkFileName(File f) {
|
||||
try {
|
||||
final match = _regex.firstMatch(path.basename(f.path));
|
||||
final match = _regex.firstMatch(f.filename);
|
||||
if (match == null) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import 'package:nc_photos/account.dart';
|
|||
import 'package:nc_photos/entity/file.dart';
|
||||
import 'package:nc_photos/event/event.dart';
|
||||
import 'package:nc_photos/use_case/move.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
class RestoreTrashbin {
|
||||
RestoreTrashbin(this.fileRepo);
|
||||
|
@ -13,7 +12,7 @@ class RestoreTrashbin {
|
|||
await Move(fileRepo)(
|
||||
account,
|
||||
file,
|
||||
"remote.php/dav/trashbin/${account.username}/restore/${path.basename(file.path)}",
|
||||
"remote.php/dav/trashbin/${account.username}/restore/${file.filename}",
|
||||
shouldOverwrite: true,
|
||||
);
|
||||
KiwiContainer()
|
||||
|
|
|
@ -5,7 +5,6 @@ import 'package:nc_photos/entity/file.dart';
|
|||
import 'package:nc_photos/exception.dart';
|
||||
import 'package:nc_photos/remote_storage_util.dart' as remote_storage_util;
|
||||
import 'package:nc_photos/use_case/ls.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
class ScanDir {
|
||||
ScanDir(this.fileRepo);
|
||||
|
@ -46,7 +45,7 @@ class ScanDir {
|
|||
/// this dir
|
||||
static bool _shouldScanIgnoreDir(Iterable<File> files) {
|
||||
return files.any((element) {
|
||||
final basename = path.basename(element.path);
|
||||
final basename = element.filename;
|
||||
return basename == ".nomedia" || basename == ".noimage";
|
||||
});
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import 'package:nc_photos/use_case/create_album.dart';
|
|||
import 'package:nc_photos/use_case/preprocess_album.dart';
|
||||
import 'package:nc_photos/use_case/update_album_with_actual_items.dart';
|
||||
import 'package:nc_photos/widget/processing_dialog.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
class AlbumImporterArguments {
|
||||
AlbumImporterArguments(this.account);
|
||||
|
@ -187,7 +186,7 @@ class _AlbumImporterState extends State<AlbumImporter> {
|
|||
),
|
||||
onPressed: onTap,
|
||||
),
|
||||
title: Text(path.basename(file.path)),
|
||||
title: Text(file.filename),
|
||||
subtitle: Text(file.strippedPath),
|
||||
onTap: onTap,
|
||||
);
|
||||
|
@ -226,7 +225,7 @@ class _AlbumImporterState extends State<AlbumImporter> {
|
|||
for (final p in _picks) {
|
||||
try {
|
||||
var album = Album(
|
||||
name: path.basename(p.path),
|
||||
name: p.filename,
|
||||
provider: AlbumDirProvider(
|
||||
dirs: [p],
|
||||
),
|
||||
|
|
|
@ -162,7 +162,7 @@ mixin DirPickerMixin<T extends StatefulWidget> on State<T> {
|
|||
icon: Icon(null),
|
||||
onPressed: null,
|
||||
),
|
||||
title: Text(path.basename(item.file.path)),
|
||||
title: Text(item.file.filename),
|
||||
trailing: item.children?.isNotEmpty == true
|
||||
? const Icon(Icons.arrow_forward_ios)
|
||||
: null,
|
||||
|
|
Loading…
Reference in a new issue