fix sendFiles wrong direction
This commit is contained in:
parent
d867decd98
commit
a962e068f8
@ -338,7 +338,8 @@ class _FileManagerPageState extends State<FileManagerPage>
|
||||
..name = file.name
|
||||
..size = FileSystemEntity.isDirectorySync(f.path) ? 0 : f.lengthSync());
|
||||
}
|
||||
model.remoteController.sendFiles(items);
|
||||
final otherSideData = model.localController.directoryData();
|
||||
model.remoteController.sendFiles(items, otherSideData);
|
||||
}
|
||||
}
|
||||
|
||||
@ -741,7 +742,9 @@ class _FileManagerViewState extends State<FileManagerView> {
|
||||
),
|
||||
onPressed: validItems(_selectedItems)
|
||||
? () {
|
||||
controller.sendFiles(_selectedItems);
|
||||
final otherSideData =
|
||||
controller.getOtherSideDirectoryData();
|
||||
controller.sendFiles(_selectedItems, otherSideData);
|
||||
_selectedItems.clear();
|
||||
}
|
||||
: null,
|
||||
|
@ -55,13 +55,15 @@ class FileModel {
|
||||
getSessionID: getSessionID,
|
||||
dialogManager: parent.target?.dialogManager,
|
||||
jobController: jobController,
|
||||
fileFetcher: fileFetcher);
|
||||
fileFetcher: fileFetcher,
|
||||
getOtherSideDirectoryData: () => remoteController.directoryData());
|
||||
remoteController = FileController(
|
||||
isLocal: false,
|
||||
getSessionID: getSessionID,
|
||||
dialogManager: parent.target?.dialogManager,
|
||||
jobController: jobController,
|
||||
fileFetcher: fileFetcher);
|
||||
fileFetcher: fileFetcher,
|
||||
getOtherSideDirectoryData: () => localController.directoryData());
|
||||
}
|
||||
|
||||
Future<void> onReady() async {
|
||||
@ -189,6 +191,12 @@ class FileModel {
|
||||
}
|
||||
}
|
||||
|
||||
class DirectoryData {
|
||||
final DirectoryOptions options;
|
||||
final FileDirectory directory;
|
||||
DirectoryData(this.directory, this.options);
|
||||
}
|
||||
|
||||
class FileController {
|
||||
final bool isLocal;
|
||||
final GetSessionID getSessionID;
|
||||
@ -205,12 +213,15 @@ class FileController {
|
||||
final JobController jobController;
|
||||
final OverlayDialogManager? dialogManager;
|
||||
|
||||
final DirectoryData Function() getOtherSideDirectoryData;
|
||||
|
||||
FileController(
|
||||
{required this.isLocal,
|
||||
required this.getSessionID,
|
||||
required this.dialogManager,
|
||||
required this.jobController,
|
||||
required this.fileFetcher});
|
||||
required this.fileFetcher,
|
||||
required this.getOtherSideDirectoryData});
|
||||
|
||||
String get homePath => options.value.home;
|
||||
|
||||
@ -229,6 +240,10 @@ class FileController {
|
||||
}
|
||||
}
|
||||
|
||||
DirectoryData directoryData() {
|
||||
return DirectoryData(directory.value, options.value);
|
||||
}
|
||||
|
||||
Future<void> onReady() async {
|
||||
options.value.home = await bind.mainGetHomeDir();
|
||||
options.value.showHidden = (await bind.sessionGetPeerOption(
|
||||
@ -372,18 +387,18 @@ class FileController {
|
||||
}
|
||||
|
||||
/// sendFiles from other side (SelectedItems) to current side (FileController.isLocal).
|
||||
void sendFiles(SelectedItems items) {
|
||||
/// ignore same side
|
||||
if (items.isLocal == isLocal) {
|
||||
void sendFiles(SelectedItems items, DirectoryData otherSideData) {
|
||||
/// ignore wrong items side status
|
||||
if (items.isLocal != isLocal) {
|
||||
return;
|
||||
}
|
||||
|
||||
// alias
|
||||
final isRemoteToLocal = isLocal;
|
||||
final isRemoteToLocal = !isLocal;
|
||||
|
||||
final toPath = directory.value.path;
|
||||
final isWindows = options.value.isWindows;
|
||||
final showHidden = options.value.showHidden;
|
||||
final toPath = otherSideData.directory.path;
|
||||
final isWindows = otherSideData.options.isWindows;
|
||||
final showHidden = otherSideData.options.showHidden;
|
||||
for (var from in items.items) {
|
||||
final jobID = jobController.add(from, isRemoteToLocal);
|
||||
bind.sessionSendFiles(
|
||||
@ -403,7 +418,7 @@ class FileController {
|
||||
|
||||
Future<void> removeAction(SelectedItems items) async {
|
||||
_removeCheckboxRemember = false;
|
||||
if (items.isLocal == isLocal) {
|
||||
if (items.isLocal != isLocal) {
|
||||
debugPrint("Failed to removeFile, wrong files");
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user