| 126 | return ReadableUnitConverter::Speed::ToString<wchar_t>(m_bytesPerSec).data(); |
| 127 | } |
| 128 | winrt::Windows::Foundation::IAsyncAction RobocopyViewModel::Start() |
| 129 | { |
| 130 | if (!m_recordFile) |
| 131 | co_return; |
| 132 | co_await m_countItemTask; |
| 133 | ProcessIOUpdater::Start(std::chrono::milliseconds{ 100 }); |
| 134 | m_status = Status::Running; |
| 135 | concurrency::create_task([this] |
| 136 | { |
| 137 | m_countItemTask.get(); |
| 138 | static uint64_t bytes{}; |
| 139 | while (*m_iter != m_recordFile->end() && m_status == Status::Running) |
| 140 | { |
| 141 | Global::UIThread.TryEnqueue([this] {raisePropertyChange(L"Source"); }); |
| 142 | if (canUseShellCopy()) |
| 143 | { |
| 144 | ShellCopy::Move(**m_iter, m_destination); |
| 145 | m_finishedFiles += m_recordFile->GetNumFiles(m_recordFile->IndexOf(*m_iter)); |
| 146 | } |
| 147 | else if (canUseRobocopy()) |
| 148 | { |
| 149 | m_process.emplace(getRobocopyArg()); |
| 150 | SetHandle(m_process->Handle()); |
| 151 | auto const ret = m_process->WaitForExit(); |
| 152 | m_finishedFiles += m_recordFile->GetNumFiles(m_recordFile->IndexOf(*m_iter)); |
| 153 | } |
| 154 | else |
| 155 | { |
| 156 | //use fallback |
| 157 | std::wstring_view destinationView{ m_destination }; |
| 158 | Global::UIThread.TryEnqueue([this, value = **m_iter] { |
| 159 | m_duplicateFiles.Append({ |
| 160 | value, |
| 161 | std::format(LR"({}\{})", m_destination.data(), std::filesystem::path{ value }.filename().wstring()) |
| 162 | }); |
| 163 | }); |
| 164 | m_hasDuplicates = true; |
| 165 | } |
| 166 | bytes += TaskFile::GetSizeOfPath(**m_iter); |
| 167 | m_copiedBytes = bytes; |
| 168 | raiseProgressChange(); |
| 169 | ++*m_iter; |
| 170 | } |
| 171 | if (*m_iter == m_recordFile->end()) |
| 172 | { |
| 173 | onNormalRobocopyFinished(); |
| 174 | } |
| 175 | if (m_hasConfirmed) |
| 176 | ConfirmDuplicates(); |
| 177 | }); |
| 178 | } |
| 179 | void RobocopyViewModel::Pause() |
| 180 | { |
| 181 | m_status = Status::Pause; |
no test coverage detected