diff --git a/ownCloud/Client/ClientQueryViewController.swift b/ownCloud/Client/ClientQueryViewController.swift index 6ae42818a..b2bffc453 100644 --- a/ownCloud/Client/ClientQueryViewController.swift +++ b/ownCloud/Client/ClientQueryViewController.swift @@ -394,7 +394,7 @@ class ClientQueryViewController: UITableViewController, Themeable { return UITableViewDropProposal(operation: .move, intent: .insertIntoDestinationIndexPath) } } else { - return UITableViewDropProposal(operation: .forbidden) + return UITableViewDropProposal(operation: .copy) } } @@ -911,47 +911,54 @@ extension ClientQueryViewController: UITableViewDropDelegate { guard let core = self.core else { return } for item in coordinator.items { - - var destinationItem: OCItem - - guard let item = item.dragItem.localObject as? OCItem, let itemName = item.name else { - return - } - - if coordinator.proposal.intent == .insertIntoDestinationIndexPath { - - guard let destinationIP = coordinator.destinationIndexPath else { + if item.dragItem.localObject != nil { + var destinationItem: OCItem + + guard let item = item.dragItem.localObject as? OCItem, let itemName = item.name else { return } - - guard items.count >= destinationIP.row else { - return + + if coordinator.proposal.intent == .insertIntoDestinationIndexPath { + + guard let destinationIP = coordinator.destinationIndexPath else { + return + } + + guard items.count >= destinationIP.row else { + return + } + + let rootItem = items[destinationIP.row] + + guard rootItem.type == .collection else { + return + } + + destinationItem = rootItem + + } else { + + guard let rootItem = self.query.rootItem, item.parentFileID != rootItem.fileID else { + return + } + + destinationItem = rootItem + } - - let rootItem = items[destinationIP.row] - - guard rootItem.type == .collection else { - return + + if let progress = core.move(item, to: destinationItem, withName: itemName, options: nil, resultHandler: { (error, _, _, _) in + if error != nil { + Log.log("Error \(String(describing: error)) moving \(String(describing: item.path))") + } + }) { + self.progressSummarizer?.startTracking(progress: progress) } - - destinationItem = rootItem - } else { - - guard let rootItem = self.query.rootItem, item.parentFileID != rootItem.fileID else { - return - } - - destinationItem = rootItem - - } - - if let progress = core.move(item, to: destinationItem, withName: itemName, options: nil, resultHandler: { (error, _, _, _) in - if error != nil { - Log.log("Error \(String(describing: error)) moving \(String(describing: item.path))") + guard let UTI = item.dragItem.itemProvider.registeredTypeIdentifiers.last else { return } + item.dragItem.itemProvider.loadFileRepresentation(forTypeIdentifier: UTI) { (url, _ error) in + guard let url = url else { return } + self.upload(itemURL: url, name: url.lastPathComponent) } - }) { - self.progressSummarizer?.startTracking(progress: progress) } } }