else
relPath = info.mid(1, pos - 1);
node = info.mid(pos + 1);
+ if (m_searchReady){
+ m_mainWindow->setLastFile(relPath, node);
+ }
copyFile(index, relPath, node);
if (m_verboseLevel > VerboseQuiet){
qint64 duration = QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch();
node = info.mid(pos + 1, pos2 - pos - 1);
QString sourceChecksum = info.mid(pos2 + 1);
+ if (m_searchReady){
+ m_mainWindow->setLastFile(relPath, node);
+ }
QByteArray checksum = buildChecksum(false, index, relPath, node);
count++;
if (! checksum.isEmpty()){
QString relPath, node;
QString info;
QDateTime start = QDateTime::currentDateTime();
- int processedFiles, hotFiles;
+ int processedFiles = 0, hotFiles = 0;
while (! m_shouldStop){
m_mutex.lock();
if (m_files.size() == 0)
relPath = info.mid(1, pos - 1);
Command command = (Command) info.at(pos + 1).unicode();
node = info.mid(pos + 2);
+ if (m_searchReady)
+ m_mainWindow->setLastFile(relPath, node);
switch(command){
case CmdRemove:
if (_unlink(I18N::s2b(relPath)) != 0){
void SearchTask::searchOneDirectory(const QString& source,
const QString& target, int index){
QDirIterator it(source);
+ m_mainWindow->setLastDirectory(source);
QString info, node;
int lengthBase = m_sourceDirs.at(index).length();
assert(index < MAX_INDEX);
}
it.next();
node = it.fileName();
+ m_mainWindow->setLastFile(node);
FILETRACE_IT(s_traceSearch, (s_traceSearch.m_fp, "?%s\n",
node.toLocal8Bit().constData()));
QFileInfo fileInfo = it.fileInfo();
} else {
prefix = QChar(1 + index) + m_separatorString;
}
+ m_mainWindow->setLastDirectory(source);
while (it.hasNext()){
if (m_shouldStop){
break;
}
it.next();
node = it.fileName();
+ m_mainWindow->setLastFile(node);
QFileInfo fileInfo = it.fileInfo();
if (! fileInfo.isSymLink() && fileInfo.isDir()){
// nothing to do
char** g_argv;
int main(int argc, char* argv[]) {
g_argv = argv;
+ ReFileUtils::m_ignoreSetUidError = true;
QString homeDir = argc > 1 ? argv[1] : "";
QApplication::setSetuidAllowed(true);
QApplication a(argc, argv);
m_searchTargetTask(NULL),
m_cleanTask(NULL),
m_errors(0),
- m_maxListSize(1000)
+ m_maxListSize(100),
+ m_mutexLastFile(),
+ m_lastFile(""),
+ m_lastDirectory("")
+
{
initializeGui();
}
switch(item.m_type){
case ReGuiQueueItem::ListEnd:
case ReGuiQueueItem::ListAppendToCurrent:
- maxItems = m_maxListSize * 2;
+ maxItems = m_maxListSize;
+ break;
+ case ReGuiQueueItem::LogError:
+ maxItems = max(100, m_maxListSize);
break;
default:
break;
say(LOG_INFO, item.m_value);
break;
case ReGuiQueueItem::LogError:
- say(LOG_ERROR, item.m_value);
+ if (m_guiQueue.countOfType(ReGuiQueueItem::LogError) <= maxItems)
+ say(LOG_ERROR, item.m_value);
break;
case ReGuiQueueItem::StatusLine:
if (++countStatusMessage % 200 != 0)
item.apply(m_guiQueue, 0);
item.m_type = ReGuiQueueItem::Undef;
}
+ m_mutexLastFile.lock();
+ ui->labelLastFile->setText(m_lastDirectory + m_lastFile);
+ m_mutexLastFile.unlock();
if (!statusMessage.isEmpty())
setStatusMessage(LOG_INFO, statusMessage);
* Starts the backup.
*/
void MainWindow::onChecksums(){
+ setLastFile("", "");
int row = ui->tableWidget->currentRow();
if (row < 0){
say(LOG_ERROR, tr("no backup item selected"));
*/
void MainWindow::onClean()
{
+ setLastFile("", "");
int row = ui->tableWidget->currentRow();
if (row < 0){
say(LOG_ERROR, tr("no backup item selected"));
* Starts the backup.
*/
void MainWindow::onStart(){
+ setLastFile("", "");
int row = ui->tableWidget->currentRow();
if (row < 0){
say(LOG_ERROR, tr("no backup item selected"));
*/
void MainWindow::onStop(){
BackupEngine::m_shouldStop = true;
+ QString message = tr("Aborted by the user");
+ m_mutexGuiQueue.lock();
+ m_guiQueue.clear();
+ m_guiQueue.pushBack(ReGuiQueueItem(ReGuiQueueItem::ReadyMessage, NULL, message));
+ m_mutexGuiQueue.unlock();
}
/**
ui->actionClean->setEnabled(! isStart);
if (isStart)
BackupEngine::m_verboseLevel = (ReVerbose_t) ui->comboBoxVerbose->currentIndex();
+ if (! isStart)
+ setStatusMessage(LOG_INFO, "");
+
}
/**
}
}
+/**
+ * Set the last processed file.
+ *
+ * Note: thread safe
+ *
+ * @param lastFile the last processed file
+ */
+void MainWindow::setLastDirectory(const QString& lastDirectory)
+{
+ m_mutexLastFile.lock();
+ m_lastDirectory = lastDirectory;
+ m_mutexLastFile.unlock();
+}
+
+/**
+ * Set the last processed file.
+ *
+ * Note: thread safe
+ *
+ * @param lastFile the last processed file
+ */
+void MainWindow::setLastFile(const QString& lastFile)
+{
+ m_mutexLastFile.lock();
+ m_lastFile = lastFile;
+ m_mutexLastFile.unlock();
+}
+
+/**
+ * Set the last processed file.
+ *
+ * Note: thread safe
+ *
+ * @param lastFile the last processed file
+ */
+void MainWindow::setLastFile(const QString& lastDir, const QString& lastFile)
+{
+ m_mutexLastFile.lock();
+ m_lastFile = lastFile;
+ m_lastDirectory = lastDir;
+ m_mutexLastFile.unlock();
+}
+
/**
* Shows the data of a given backup item in the gui elements.
*
virtual bool say(ReLoggerLevel level, const QString& message);
void startStop(bool isStart);
void restoreState();
+ void setLastDirectory(const QString& lastFile);
+ void setLastFile(const QString& lastFile);
+ void setLastFile(const QString& lastDir, const QString& lastFile);
void saveState();
protected slots:
private:
CleanTask* m_cleanTask;
int m_errors;
int m_maxListSize;
+ QMutex m_mutexLastFile;
+ QString m_lastFile;
+ QString m_lastDirectory;
};
#endif // MAINWINDOW_HPP
<string>Verbose level</string>
</property>
<property name="currentIndex">
- <number>2</number>
+ <number>1</number>
</property>
<item>
<property name="text">
</widget>
</widget>
</item>
+ <item>
+ <widget class="QLabel" name="labelLastFile">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
<widget class="QMenuBar" name="menuBar">
<x>0</x>
<y>0</y>
<width>839</width>
- <height>29</height>
+ <height>31</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
LOC_SET_TIMES_2, // 12507
};
int ReFileUtils::m_maxCharSet = 128;
+bool ReFileUtils::m_ignoreSetUidError = false;
QDateTime ReFileUtils::m_undefinedTime;
#ifdef __linux__
if (setUser){
if (chown(target2.constData(), sourceInfo->ownerId(),
- sourceInfo->groupId()) != 0 && rc.isEmpty()){
- rc = QObject::tr("cannot set user/gid (%1): %2")
+ sourceInfo->groupId()) != 0
+ && ! m_ignoreSetUidError && rc.isEmpty()){
+ rc = QObject::tr("cannot set user/gid [%1/%2] (%3): %4")
+ .arg(sourceInfo->ownerId()).arg(sourceInfo->groupId())
.arg(errno).arg(target);
}
}
static QDateTime m_undefinedTime;
/// see modifyToNonExisting()
static int m_maxCharSet;
+ static bool m_ignoreSetUidError;
};
#endif // REFILEUTILS_HPP
int count() const;
ReGuiQueueItem popFront();
void pushBack(const ReGuiQueueItem& item);
+ /**
+ * Delete all elements.
+ */
+ inline void clear(){
+ QList::clear();
+ }
+ /**
+ * Returns the count of items with a given type
+ * @param type the type to search
+ * @return the count of items with a given type
+ */
inline int countOfType(ReGuiQueueItem::WidgetType type) const {
return m_countOfType[type];
}
+ /**
+ * Returns the last of the items with a given type read from the queue.
+ * @param type the type to search
+ * @return the last of the items with a given type read from the queue
+ */
inline ReGuiQueueItem& lastOfType(ReGuiQueueItem::WidgetType type){
return m_lastOfType[type];
}