文件移动失败时,尝试9次

This commit is contained in:
gb 2022-09-19 18:41:23 +08:00
parent 027f627365
commit 8c1474ab3d
1 changed files with 15 additions and 5 deletions

View File

@ -1183,6 +1183,7 @@ Twpp::Result huagao_ds::imageFileXferGet(const Twpp::Identity& origin)
DeleteFileA(file.c_str());
}
int cv_e = 0;
if (ret.status() == ConditionCode::Success && m_fileXfer.format() != ImageFileFormat::Bmp)
{
SANE_ImageFormatConvert conv;
@ -1202,16 +1203,25 @@ Twpp::Result huagao_ds::imageFileXferGet(const Twpp::Identity& origin)
conv.dst.is_file = SANE_TRUE;
conv.dst.data = target.c_str();
conv.dst.data_len = target.length();
MoveFileA(target.c_str(), file.c_str());
if(scanner_->convert_image(&conv) != SCANNER_ERR_OK)
while (!MoveFileA(target.c_str(), file.c_str()))
{
if (++cv_e >= 9)
break;
Sleep(30);
}
if (cv_e < 9)
{
cv_e = scanner_->convert_image(&conv);
if (cv_e != SCANNER_ERR_OK)
ret = { ReturnCode::Failure, ConditionCode::OperationError };
DeleteFileA(file.c_str());
}
}
{
std::wstring info(load_sane_util::ansi2unic(m_fileXfer.filePath().string().c_str()));
wchar_t r[80] = { 0 };
swprintf_s(r, _countof(r) - 1, L": result = %d\r\n", ret.returnCode());
swprintf_s(r, _countof(r) - 1, L": status = %d(convert: 0x%x)\r\n", ret.status(), cv_e);
load_sane_util::log_info((info + r).c_str(), 0);
}
}