| @@ 34-50 (lines=17) @@ | ||
| 31 | * @return FileNode |
|
| 32 | * @throws TransferFailedException |
|
| 33 | */ |
|
| 34 | public function copyTo(FileNode $from, FileNode $to) |
|
| 35 | { |
|
| 36 | $mountManager = new MountManager([ |
|
| 37 | 'from' => $from->getFilesystem(), |
|
| 38 | 'to' => $to->getFilesystem(), |
|
| 39 | ]); |
|
| 40 | ||
| 41 | $this->log(LogLevel::INFO, "Copying file from: '{from}', to: '{to}'", [ |
|
| 42 | 'from' => $from, |
|
| 43 | 'to' => $to, |
|
| 44 | ]); |
|
| 45 | if (!$mountManager->copy('from://' . $from->getPath(), 'to://' . $to->getPath())) { |
|
| 46 | throw new TransferFailedException($from, $to); |
|
| 47 | } |
|
| 48 | ||
| 49 | return $to; |
|
| 50 | } |
|
| 51 | ||
| 52 | /** |
|
| 53 | * @param FileNode $from |
|
| @@ 59-75 (lines=17) @@ | ||
| 56 | * @return FileNode |
|
| 57 | * @throws TransferFailedException |
|
| 58 | */ |
|
| 59 | public function moveTo(FileNode $from, FileNode $to) |
|
| 60 | { |
|
| 61 | $mountManager = new MountManager([ |
|
| 62 | 'from' => $from->getFilesystem(), |
|
| 63 | 'to' => $to->getFilesystem(), |
|
| 64 | ]); |
|
| 65 | ||
| 66 | $this->log(LogLevel::INFO, "Moving file from: '{from}', to: '{to}'", [ |
|
| 67 | 'from' => $from, |
|
| 68 | 'to' => $to, |
|
| 69 | ]); |
|
| 70 | if (!$mountManager->move('from://' . $from->getPath(), 'to://' . $to->getPath())) { |
|
| 71 | throw new TransferFailedException($from, $to); |
|
| 72 | } |
|
| 73 | ||
| 74 | return $to; |
|
| 75 | } |
|
| 76 | } |
|
| 77 | ||