Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions QtProject/app/db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,37 @@ bool Db::emptyAllDb(const Prefs prefs){
return true;
}

QString Db::getActualCacheLocationForDisplay(const QString &logicalPath) {
#ifdef Q_OS_WIN
// Check if we're running as a UWP app by looking for package identity
// UWP apps have a specific environment or registry indicators
QString packagePath = qgetenv("LOCALAPPDATA");
if (!packagePath.isEmpty()) {
// Look for the UWP package directory pattern
QString packagesDir = packagePath + "/Packages";
QDir packages(packagesDir);
if (packages.exists()) {
// Look for our app's package directory
QStringList packageDirs = packages.entryList(QStringList() << "5743TheophaneMayaud.Videosimiliduplicatecleaner_*", QDir::Dirs);
if (!packageDirs.isEmpty()) {
// Found our UWP package directory, construct the actual cache path
QString packageDir = packageDirs.first();
QString uwpCachePath = packagesDir + "/" + packageDir + "/LocalCache/Local/Video simili duplicate cleaner/cache/cache.db";

// Check if this path actually exists (indicating we're running as UWP)
QFileInfo uwpCacheFile(uwpCachePath);
if (uwpCacheFile.exists() || uwpCacheFile.dir().exists()) {
return QDir::toNativeSeparators(uwpCachePath);
}
}
}
}
#endif

// Fall back to the original logical path for non-UWP or if UWP detection failed
return QDir::toNativeSeparators(logicalPath);
}

// -------------------- END : public static functions -------------------
// ----------------------------------------------------------------------

Expand Down
5 changes: 5 additions & 0 deletions QtProject/app/db.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <QStandardPaths>
#include <QFileDialog>
#include <QMessageBox>
#include <QDir>
#include <QFileInfo>

#include "prefs.h"
#include "video.h"
Expand Down Expand Up @@ -38,6 +40,9 @@ class Db

static bool emptyAllDb(const Prefs prefs);

// Get the actual cache location for display purposes (handles UWP redirection)
static QString getActualCacheLocationForDisplay(const QString &logicalPath);

// //return md5 hash of parameter's file, used internally as "unique id" for each file
// static QString pathnameHashId(const QString &filename=QStringLiteral(""));

Expand Down
10 changes: 5 additions & 5 deletions QtProject/app/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ MainWindow::MainWindow() : ui(new Ui::MainWindow)
ui->mainToolBar->setVisible(false);

if(Db::initDbAndCacheLocation(_prefs))
addStatusMessage("\nCache located at: " + _prefs.cacheFilePathName() + "\n");
addStatusMessage("\nCache located at: " + Db::getActualCacheLocationForDisplay(_prefs.cacheFilePathName()) + "\n");
else
addStatusMessage("\nError accessing cache, will not use any.\n");

Expand Down Expand Up @@ -470,15 +470,15 @@ void MainWindow::on_actionAbout_triggered()
void MainWindow::on_actionEmpty_cache_triggered()
{
if(Db::emptyAllDb(_prefs))
addStatusMessage(QString("\nEmptied cache at: %1\n").arg(_prefs.cacheFilePathName()));
addStatusMessage(QString("\nEmptied cache at: %1\n").arg(Db::getActualCacheLocationForDisplay(_prefs.cacheFilePathName())));
else
addStatusMessage(QString("\nFailed to empty cache at: %1\n").arg(_prefs.cacheFilePathName()));
addStatusMessage(QString("\nFailed to empty cache at: %1\n").arg(Db::getActualCacheLocationForDisplay(_prefs.cacheFilePathName())));
}

void MainWindow::on_actionSet_custom_cache_location_triggered()
{
if(Db::initCustomDbAndCacheLocation(_prefs)){
addStatusMessage(QString("\nCache now used: %1\n").arg(_prefs.cacheFilePathName()));
addStatusMessage(QString("\nCache now used: %1\n").arg(Db::getActualCacheLocationForDisplay(_prefs.cacheFilePathName())));
}
else
addStatusMessage(QString("\nError selecting custom cache. Probably no cache now.\n"));
Expand Down Expand Up @@ -508,7 +508,7 @@ void MainWindow::on_actionRestore_default_cache_location_triggered()
{
_prefs.cacheFilePathName("");
if(Db::initDbAndCacheLocation(_prefs))
addStatusMessage("\nCache restored to: " + _prefs.cacheFilePathName() + "\n");
addStatusMessage("\nCache restored to: " + Db::getActualCacheLocationForDisplay(_prefs.cacheFilePathName()) + "\n");
else
addStatusMessage(QString("\nError restoring default cache. Probably no cache now.\n"));
}
Expand Down