提交 a1894671 编写于 作者: M manjaro-xfce

Fopen Test Files Will broke the entire progress.

上级 92be51a5
......@@ -52,8 +52,12 @@ void DialogFileLoadCtrl::cleanFile()
break;
qint64 tmf = m_cache_files.begin()->first;
QMap<QString,QFileInfo> & mp = m_cache_files[tmf];
QMap<QString,qint64> & ms = m_cache_sizes[tmf];
if (!mp.size())
{
m_cache_files.erase(tmf);
m_cache_sizes.erase(tmf);
}
else
{
QString fm = mp.begin().key();
......@@ -90,8 +94,12 @@ void DialogFileLoadCtrl::cleanFile()
slot_msg(msg);
}
mp.remove(fm);
ms.remove(fm);
if (!mp.size())
{
m_cache_files.erase(tmf);
m_cache_sizes.erase(tmf);
}
}
if (++cm % 10==0)
......@@ -118,29 +126,34 @@ void DialogFileLoadCtrl::updateMap()
foreach (QFileInfo i, lst)
{
QString fm = i.absoluteFilePath();
QFile ft(fm);
if (ft.open(QIODevice::ReadOnly))
long long sz = i.size();
qint64 tm = i.fileTime(QFile::FileBirthTime).toMSecsSinceEpoch();
//Judge Whether this file need to be copied.
bool NeedTrans = false;
//1. Type
QString strExt = i.suffix().toUpper().trimmed();
if (strExt.length()<1)
strExt=":";
if (FMUpper.contains(strExt) || FMUpper.isEmpty())
{
ft.close();
unsigned long long sz = i.size();
qint64 tm = i.fileTime(QFile::FileBirthTime).toMSecsSinceEpoch();
//新文件
if (!m_cache_files[tm].contains(fm))
//判断大小
if (i.size()>=bfMin && i.size()<=bfMax)
{
//判断类型
QString strExt = i.suffix().toUpper().trimmed();
if (strExt.length()<1)
strExt=":";
if (FMUpper.contains(strExt) || FMUpper.isEmpty())
TransFile(i);
}
m_cache_files[tm][fm] = i;
m_total_size += sz;
++m_total_files;
//2. Size Range
if (sz>=bfMin && sz<=bfMax)
{
//3.First Descovered
if (!m_cache_files[tm].contains(fm))
NeedTrans = true;
//4.Size Changed
else if (m_cache_sizes[tm][fm]!=sz)
NeedTrans = true;
}
}
if (NeedTrans)
TransFile(i);
m_cache_files[tm][fm] = i;
m_cache_sizes[tm][fm] = sz;
m_total_size += sz;
++m_total_files;
}
QString msg = tr("Enuming %1 Files %2 Bytes.").arg(m_total_files).arg(m_total_size);
......@@ -175,12 +188,12 @@ void DialogFileLoadCtrl::TransFile(QFileInfo ifile)
QString msg;
std::atomic<bool> bOk (false);
std::thread t([&]()->void{
if (true==QFile::copy(ifile.absoluteFilePath(),dstFile))
msg = tr("Succ Copy %1 to %2.").arg( ifile.absoluteFilePath()).arg(dstFile);
else
msg = tr("Fail Copy %1 to %2.").arg( ifile.absoluteFilePath()).arg(dstFile);
bOk = true;
});
if (true==QFile::copy(ifile.absoluteFilePath(),dstFile))
msg = tr("Succ Copy %1 to %2.").arg(ifile.absoluteFilePath()).arg(dstFile);
else
msg = tr("Busy File %1 with %2 Bytes.").arg( ifile.absoluteFilePath()).arg(ifile.size());
bOk = true;
});
//Hold and wait
slot_next_prg(0);
quint8 trc = 0;
......@@ -304,11 +317,6 @@ void DialogFileLoadCtrl::saveSettings()
}
void DialogFileLoadCtrl::on_doubleSpinBox_maxSz_valueChanged(double /*arg1*/)
{
saveSettings();
}
void DialogFileLoadCtrl::on_checkBox_watch_clicked()
{
saveSettings();
......
......@@ -31,7 +31,6 @@ private slots:
void slot_next_prg(int v);
void on_pushButton_br_src_clicked();
void on_pushButton_br_dst_clicked();
void on_doubleSpinBox_maxSz_valueChanged(double arg1);
void on_checkBox_watch_clicked();
private:
......@@ -42,6 +41,7 @@ private:
QStandardItemModel * m_pMsgMd = 0;
int m_nTimer = -1;
std::map<qint64,QMap<QString,QFileInfo> > m_cache_files;
std::map<qint64,QMap<QString,qint64> > m_cache_sizes;
qint64 m_total_size = 0;
qint64 m_total_files = 0;
};
......
......@@ -80,42 +80,47 @@
<translation>完成.</translation>
</message>
<message>
<location filename="dialogfileloadctrl.cpp" line="89"/>
<location filename="dialogfileloadctrl.cpp" line="93"/>
<source>Fail Deleting %1.</source>
<translation>删除文件失败:%1.</translation>
</message>
<message>
<location filename="dialogfileloadctrl.cpp" line="64"/>
<location filename="dialogfileloadctrl.cpp" line="194"/>
<source>Busy File %1 with %2 Bytes.</source>
<oldsource>Busy File %1 Bytes.</oldsource>
<translation>文件尚在繁忙: %1 ,%2 字节.</translation>
</message>
<message>
<location filename="dialogfileloadctrl.cpp" line="68"/>
<source>Force Deleting %1.</source>
<translation>强制删除文件:%1.</translation>
</message>
<message>
<location filename="dialogfileloadctrl.cpp" line="84"/>
<location filename="dialogfileloadctrl.cpp" line="88"/>
<source>Succ Deleting %1.</source>
<translation>删除文件成功:%1.</translation>
</message>
<message>
<location filename="dialogfileloadctrl.cpp" line="146"/>
<location filename="dialogfileloadctrl.cpp" line="159"/>
<source>Enuming %1 Files %2 Bytes.</source>
<translation>当前枚举到 %1 个文件占用 %2 字节.</translation>
</message>
<message>
<location filename="dialogfileloadctrl.cpp" line="179"/>
<location filename="dialogfileloadctrl.cpp" line="192"/>
<source>Succ Copy %1 to %2.</source>
<translation>备份文件成功:%1 %2.</translation>
</message>
<message>
<location filename="dialogfileloadctrl.cpp" line="181"/>
<source>Fail Copy %1 to %2.</source>
<translation>备份文件失败:%1 %2.</translation>
<translation type="vanished">备份文件失败:%1 %2.</translation>
</message>
<message>
<location filename="dialogfileloadctrl.cpp" line="239"/>
<location filename="dialogfileloadctrl.cpp" line="252"/>
<source>Watching root</source>
<translation>配额监视根文件夹</translation>
</message>
<message>
<location filename="dialogfileloadctrl.cpp" line="249"/>
<location filename="dialogfileloadctrl.cpp" line="262"/>
<source>backup root</source>
<translation>备份目的根文件夹</translation>
</message>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册