.metadata
2github
+.rebackgui.target
+appl/build-rebackgui-Desktop_Qt_5_6_0_GCC_64bit-Debug/
+appl/rebackgui/.rebackgui.target
}
}
+/**
+ * Creates the base directory for shadowing.
+ *
+ * @param base the full path of the base directory
+ * @return <code>true</code>: the base directory exists and is writeable
+ */
+bool SearchTargetTask::ensureShadowBase(const QString& base){
+ bool rc = ReFileUtils::isDirectory(base);
+ if (! rc){
+#if defined __linux__
+ QStringList args;
+ args << "/bin/mkdir" << base;
+ QByteArray errorMsg;
+ ReSuccess_t rc2 = ReProcess::executeSilent("/usr/bin/sudo", args, 30, &errorMsg);
+ if (! rc2)
+ error(QString(errorMsg));
+
+ rc = ReFileUtils::isDirectory(base);
+#endif
+ }
+#if defined __linux__
+ if (rc){
+ QStringList args;
+ args.clear(); args << "/bin/chmod" << "uog=rwx" << base;
+ QByteArray errorMsg;
+ ReSuccess_t rc2 = ReProcess::executeSilent("/usr/bin/sudo", args, 30, &errorMsg);
+ if (! rc2)
+ error(QString(errorMsg));
+ }
+#endif
+ return rc;
+}
+
/**
* Moves a target directory to the shadow directory and delegate the removing files.
*
QString targetName = shadowDir;
int pos = targetName.length() / 2;
while(pos < shadowDir.length()){
- char cc = '0' - 1;
- do{
- targetName[pos] = ++cc;
- } while (cc <= 'Z' && QFileInfo(targetName).exists());
- if (cc <= 'Z'){
- if (rename(I18N::s2b(shadowDir).constData(),
- I18N::s2b(targetName).constData()) != 0)
- error(QObject::tr("kann Schattenverzeichnis nicht umbenennen: %1 -> %2")
- .arg(shadowDir, targetName));
- else break;
- }
- pos++;
+ char cc = '0' - 1;
+ do{
+ targetName[pos] = ++cc;
+ } while (cc <= 'Z' && QFileInfo(targetName).exists());
+ if (cc <= 'Z'){
+ if (rename(I18N::s2b(shadowDir).constData(),
+ I18N::s2b(targetName).constData()) != 0)
+ error(QObject::tr("kann Schattenverzeichnis nicht umbenennen: %1 -> %2")
+ .arg(shadowDir, targetName));
+ else break;
+ }
+ pos++;
}
-
}
if (! ReFileUtils::makeDirWithParents(shadowDir)){
qint64 start = QDateTime::currentMSecsSinceEpoch();
m_searchReady = false;
QString targetDir, sourceDir;
+ ensureShadowBase(m_shadowBaseDir);
for (int ix = 0; ! m_shouldStop && ix < m_sourceDirs.size(); ix++){
sourceDir = m_sourceDirs.at(ix);
targetDir = m_targetDirs.at(ix);
public:
virtual void run();
private:
+ bool ensureShadowBase(const QString& base);
void moveToShadow(const QString& target, const QString& relPath, int index);
bool removeOlder(const QString& directory, const QDateTime& time);
void searchOneDirectory(const QString& target, const QString& source,
enum {
LOC_FIND_TARGET_1 = LOC_FIRST_OF(LOC_REBACKGUI_BACKUPUTILS), // 20501
LOC_FIND_TARGET_2, // 20502
+ LOC_FIND_TARGET_3, // 20503
};
rc = item.m_target.mid(1);
} else {
ReBlockDevices& devices = ReBlockDevices::instance();
- QStringList parts = item.m_target.split(';');
- QStringList args;
- QString label = parts.at(0);
- QString relativePath = parts.at(1);
- if (label.startsWith("L="))
- label = label.mid(2);
- const ReBlockDevice* device = devices.findByLabel(label);
- if (device != NULL){
- ReMountInfo& mountInfo = ReMountInfo::instance();
- if (mountInfo.m_mountPointOfDevice.contains(device->m_device)){
- rc = mountInfo.m_mountPointOfDevice.value(device->m_device);
- + OS_SEPARATOR + relativePath;
- } else {
- QStringList args;
- QString mountPath = "/media/" + label;
- ReFileUtils::makeDir(mountPath, mainWindow.logger());
+ if (item.m_target.indexOf(';') < 0) {
+ mainWindow.say(LOG_ERROR, QObject::tr("wrong target format. Missing ';': %1").arg(
+ item.m_target));
+ } else {
+ QStringList parts = item.m_target.split(';');
+ QStringList args;
+ QString label = parts.at(0);
+ QString relativePath = parts.at(1);
+ if (label.startsWith("L="))
+ label = label.mid(2);
+ const ReBlockDevice* device = devices.findByLabel(label);
+ if (device != NULL){
+ ReMountInfo& mountInfo = ReMountInfo::instance();
+ if (mountInfo.m_mountPointOfDevice.contains(device->m_device)){
+ rc = mountInfo.m_mountPointOfDevice.value(device->m_device)
+ + OS_SEPARATOR + relativePath;
+ } else {
+ QStringList args;
+ QString mountPath = "/media/" + label;
+ ReFileUtils::makeDir(mountPath, mainWindow.logger());
- if (ReMountInfo::mount(device->m_device, mountPath, &mainWindow)){
- tempoararyMounted = device->m_device;
- }
- }
- }
- }
+ if (ReMountInfo::mount(device->m_device, mountPath, &mainWindow)){
+ tempoararyMounted = device->m_device;
+ }
+ }
+ }
+ }
+ }
#elif defined _WIN32
(void) tempoararyMounted;
QStringList drives = ReFileUtils::findRootDirs();
#include "base/retrace.hpp"
DECLARE_TRACER(s_traceMain, "/tmp/bup_main.log");
-const QString VERSION("2016.06.01");
+const QString VERSION("2016.10.01");
/**
* Constructor.
--- /dev/null
+../../base/ReProcess.cpp
\ No newline at end of file