mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-07 13:38:13 -08:00
fix: Sync basename parsing for different hosts (#583)
This commit is contained in:
parent
2f7328c954
commit
52c12e63b6
2 changed files with 11 additions and 2 deletions
|
|
@ -3,6 +3,7 @@ import 'dart:convert';
|
|||
import 'dart:developer';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:fladder/util/string_extensions.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart' hide ConnectionState;
|
||||
|
||||
|
|
@ -620,11 +621,11 @@ extension SyncNotifierHelpers on SyncNotifier {
|
|||
if (parent == null) {
|
||||
await _db.insertItem(syncItem);
|
||||
}
|
||||
|
||||
|
||||
return syncItem.copyWith(
|
||||
fileSize: response.mediaSources?.firstOrNull?.size ?? 0,
|
||||
syncing: false,
|
||||
videoFileName: response.path?.split('/').lastOrNull ?? "",
|
||||
videoFileName: response.path?.universalBasename ?? "",
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import 'package:fladder/models/items/item_shared_models.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
extension StringExtensions on String {
|
||||
String capitalize() {
|
||||
|
|
@ -49,6 +50,13 @@ extension StringExtensions on String {
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// Supports both Linux and Windows server path separators as referenced in [path.separator].
|
||||
/// Instead of the [path.basename] method, which returns the last part of the path for the current client platform.
|
||||
String get universalBasename {
|
||||
final parts = split(RegExp(r'[\\/]+'));
|
||||
return parts.where((s)=>s.isNotEmpty).lastOrNull ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
extension ListExtensions on List<String> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue