Merge branch 'test-ubx-fixes' into dev-qt5.1x

preferencesAboutTextFull
Clément Fauconnier 4 years ago
commit a0c3c87b4b
  1. 12
      src/adaptors/UBImportDocumentSetAdaptor.cpp
  2. 2
      src/document/UBDocumentController.cpp
  3. 7
      src/frameworks/UBFileSystemUtils.cpp
  4. 2
      src/frameworks/UBFileSystemUtils.h

@ -94,11 +94,17 @@ QFileInfoList UBImportDocumentSetAdaptor::importData(const QString &zipFile, con
foreach(QFileInfo readDir, tDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden , QDir::Name)) {
QString newFileName = readDir.fileName();
if (QFileInfo(destination + "/" + readDir.fileName()).exists()) {
newFileName = QFileInfo(UBPersistenceManager::persistenceManager()->generateUniqueDocumentPath(tmpDir)).fileName();
if (QFileInfo(destination + "/" + newFileName).exists())
{
//if the generateUniqueDocumentPath is called twice in the same millisecond, the destination files are overwritten
do
{
newFileName = QFileInfo(UBPersistenceManager::persistenceManager()->generateUniqueDocumentPath(tmpDir)).fileName();
} while (QFileInfo(destination + "/" + newFileName).exists());
}
QString newFilePath = destination + "/" + newFileName;
if (UBFileSystemUtils::copy(readDir.absoluteFilePath(), newFilePath)) {
if (UBFileSystemUtils::copy(readDir.absoluteFilePath(), newFilePath, true)) {
result.append(newFilePath);
}
}

@ -2786,6 +2786,8 @@ void UBDocumentController::importFile()
if (fileInfo.suffix().toLower() == "ubx") {
UBPersistenceManager::persistenceManager()->createDocumentProxiesStructure(docManager->importUbx(filePath, UBSettings::userDocumentDirectory()), true);
emit documentThumbnailsUpdated(this); // some documents might have been overwritten while not having the same page count
} else {
UBSettings::settings()->lastImportFilePath->set(QVariant(fileInfo.absolutePath()));

@ -121,7 +121,7 @@ bool UBFileSystemUtils::copyFile(const QString &source, const QString &destinati
bool UBFileSystemUtils::copy(const QString &source, const QString &destination, bool overwrite)
{
if (QFileInfo(source).isDir()) {
return copyDir(source, destination);
return copyDir(source, destination, overwrite);
} else {
return copyFile(source, destination, overwrite);
}
@ -280,7 +280,7 @@ bool UBFileSystemUtils::deleteDir(const QString& pDirPath)
}
bool UBFileSystemUtils::copyDir(const QString& pSourceDirPath, const QString& pTargetDirPath)
bool UBFileSystemUtils::copyDir(const QString& pSourceDirPath, const QString& pTargetDirPath, bool overwite)
{
if (pSourceDirPath == "" || pSourceDirPath == "." || pSourceDirPath == "..")
return false;
@ -304,8 +304,7 @@ bool UBFileSystemUtils::copyDir(const QString& pSourceDirPath, const QString& pT
}
else
{
QFile f(pSourceDirPath + "/" + dirContent.fileName());
successSoFar = f.copy(pTargetDirPath + "/" + dirContent.fileName());
successSoFar = copyFile(pSourceDirPath + "/" + dirContent.fileName(), pTargetDirPath + "/" + dirContent.fileName(), overwite);
}
}
else

@ -62,7 +62,7 @@ class UBFileSystemUtils : public QObject
static bool deleteDir(const QString& pDirPath);
static bool copyDir(const QString& pSourceDirPath, const QString& pTargetDirPath);
static bool copyDir(const QString& pSourceDirPath, const QString& pTargetDirPath, bool overwrite = false);
static bool moveDir(const QString& pSourceDirPath, const QString& pTargetDirPath);

Loading…
Cancel
Save