This commit is contained in:
DavidXanatos 2023-02-03 08:00:11 +01:00
parent 004d7db5a8
commit 779903395d
10 changed files with 30 additions and 30 deletions

View File

@ -13,7 +13,7 @@ SB_PROGRESS CCleanUpJob::Start()
CSandBoxPlus* pBox = GetBox(); CSandBoxPlus* pBox = GetBox();
SB_PROGRESS Status; SB_PROGRESS Status;
if (!m_DeleteShapshots && pBox->HasSnapshots()) { if (!m_DeleteSnapshots && pBox->HasSnapshots()) {
QString Current; QString Current;
QString Default = pBox->GetDefaultSnapshot(&Current); QString Default = pBox->GetDefaultSnapshot(&Current);
if (m_bOnAutoDelete) { if (m_bOnAutoDelete) {

View File

@ -32,9 +32,9 @@ class CCleanUpJob : public CBoxJob
{ {
protected: protected:
friend CSandBoxPlus; friend CSandBoxPlus;
CCleanUpJob(CSandBoxPlus* pBox, bool DeleteShapshots = true, bool bOnAutoDelete = false) : CBoxJob((QObject*)pBox) { CCleanUpJob(CSandBoxPlus* pBox, bool DeleteSnapshots = true, bool bOnAutoDelete = false) : CBoxJob((QObject*)pBox) {
m_Description = tr("Deleting Content"); m_Description = tr("Deleting Content");
m_DeleteShapshots = DeleteShapshots; m_DeleteSnapshots = DeleteSnapshots;
m_bOnAutoDelete = bOnAutoDelete; m_bOnAutoDelete = bOnAutoDelete;
} }
@ -42,7 +42,7 @@ protected:
virtual void Finished(); virtual void Finished();
protected: protected:
bool m_DeleteShapshots; bool m_DeleteSnapshots;
bool m_bOnAutoDelete; bool m_bOnAutoDelete;
}; };

View File

@ -1513,7 +1513,7 @@ void CSandMan::OnBoxSelected()
} }
} }
SB_STATUS CSandMan::DeleteBoxContent(const CSandBoxPtr& pBox, EDelMode Mode, bool DeleteShapshots) SB_STATUS CSandMan::DeleteBoxContent(const CSandBoxPtr& pBox, EDelMode Mode, bool DeleteSnapshots)
{ {
SB_STATUS Ret = SB_OK; SB_STATUS Ret = SB_OK;
m_iDeletingContent++; m_iDeletingContent++;
@ -1541,7 +1541,7 @@ SB_STATUS CSandMan::DeleteBoxContent(const CSandBoxPtr& pBox, EDelMode Mode, boo
{ {
SB_PROGRESS Status; SB_PROGRESS Status;
if (Mode != eForDelete && !DeleteShapshots && pBox->HasSnapshots()) { // in auto delete mode always return to last snapshot if (Mode != eForDelete && !DeleteSnapshots && pBox->HasSnapshots()) { // in auto delete mode always return to last snapshot
QString Current; QString Current;
QString Default = pBox->GetDefaultSnapshot(&Current); QString Default = pBox->GetDefaultSnapshot(&Current);
Status = pBox->SelectSnapshot(Mode == eAuto ? Current : Default); Status = pBox->SelectSnapshot(Mode == eAuto ? Current : Default);
@ -1730,9 +1730,9 @@ void CSandMan::OnBoxClosed(const CSandBoxPtr& pBox)
{ {
if (pBox->GetBool("AutoDelete", false)) if (pBox->GetBool("AutoDelete", false))
{ {
bool DeleteShapshots = false; bool DeleteSnapshots = false;
// if this box auto deletes first show the recovry dialog with the option to abort deletion // if this box auto deletes first show the recovry dialog with the option to abort deletion
if (!theGUI->OpenRecovery(pBox, DeleteShapshots, true)) // unless no files are found than continue silently if (!theGUI->OpenRecovery(pBox, DeleteSnapshots, true)) // unless no files are found than continue silently
return; return;
if (theConf->GetBool("Options/AutoBoxOpsNotify", false)) if (theConf->GetBool("Options/AutoBoxOpsNotify", false))
@ -1741,11 +1741,11 @@ void CSandMan::OnBoxClosed(const CSandBoxPtr& pBox)
if (theConf->GetBool("Options/UseAsyncBoxOps", false) || IsSilentMode()) if (theConf->GetBool("Options/UseAsyncBoxOps", false) || IsSilentMode())
{ {
auto pBoxEx = pBox.objectCast<CSandBoxPlus>(); auto pBoxEx = pBox.objectCast<CSandBoxPlus>();
SB_STATUS Status = pBoxEx->DeleteContentAsync(DeleteShapshots); SB_STATUS Status = pBoxEx->DeleteContentAsync(DeleteSnapshots);
CheckResults(QList<SB_STATUS>() << Status); CheckResults(QList<SB_STATUS>() << Status);
} }
else else
DeleteBoxContent(pBox, eAuto, DeleteShapshots); DeleteBoxContent(pBox, eAuto, DeleteSnapshots);
} }
} }
} }

View File

@ -44,7 +44,7 @@ public:
eForDelete eForDelete
}; };
SB_STATUS DeleteBoxContent(const CSandBoxPtr& pBox, EDelMode Mode, bool DeleteShapshots = true); SB_STATUS DeleteBoxContent(const CSandBoxPtr& pBox, EDelMode Mode, bool DeleteSnapshots = true);
SB_STATUS AddAsyncOp(const CSbieProgressPtr& pProgress, bool bWait = false, const QString& InitialMsg = QString()); SB_STATUS AddAsyncOp(const CSbieProgressPtr& pProgress, bool bWait = false, const QString& InitialMsg = QString());
static QString FormatError(const SB_STATUS& Error); static QString FormatError(const SB_STATUS& Error);
@ -154,7 +154,7 @@ public slots:
void OnFileToRecover(const QString& BoxName, const QString& FilePath, const QString& BoxPath, quint32 ProcessId); void OnFileToRecover(const QString& BoxName, const QString& FilePath, const QString& BoxPath, quint32 ProcessId);
void OnFileRecovered(const QString& BoxName, const QString& FilePath, const QString& BoxPath); void OnFileRecovered(const QString& BoxName, const QString& FilePath, const QString& BoxPath);
bool OpenRecovery(const CSandBoxPtr& pBox, bool& DeleteShapshots, bool bCloseEmpty = false); bool OpenRecovery(const CSandBoxPtr& pBox, bool& DeleteSnapshots, bool bCloseEmpty = false);
class CRecoveryWindow* ShowRecovery(const CSandBoxPtr& pBox, bool bFind = true); class CRecoveryWindow* ShowRecovery(const CSandBoxPtr& pBox, bool bFind = true);
void UpdateSettings(bool bRebuildUI); void UpdateSettings(bool bRebuildUI);

View File

@ -23,7 +23,7 @@ void CSandMan::OnFileToRecover(const QString& BoxName, const QString& FilePath,
m_pPopUpWindow->AddFileToRecover(FilePath, BoxPath, pBox, ProcessId); m_pPopUpWindow->AddFileToRecover(FilePath, BoxPath, pBox, ProcessId);
} }
bool CSandMan::OpenRecovery(const CSandBoxPtr& pBox, bool& DeleteShapshots, bool bCloseEmpty) bool CSandMan::OpenRecovery(const CSandBoxPtr& pBox, bool& DeleteSnapshots, bool bCloseEmpty)
{ {
auto pBoxEx = pBox.objectCast<CSandBoxPlus>(); auto pBoxEx = pBox.objectCast<CSandBoxPlus>();
if (!pBoxEx) return false; if (!pBoxEx) return false;
@ -47,7 +47,7 @@ bool CSandMan::OpenRecovery(const CSandBoxPtr& pBox, bool& DeleteShapshots, bool
if (pBoxEx->m_pRecoveryWnd->exec() != 1) if (pBoxEx->m_pRecoveryWnd->exec() != 1)
return false; return false;
} }
DeleteShapshots = pRecoveryWnd->IsDeleteShapshots(); DeleteSnapshots = pRecoveryWnd->IsDeleteSnapshots();
return true; return true;
} }

View File

@ -386,9 +386,9 @@ bool CSandBoxPlus::IsBoxexPath(const QString& Path)
return Path.left(m_FilePath.length()).compare(m_FilePath, Qt::CaseInsensitive) == 0; return Path.left(m_FilePath.length()).compare(m_FilePath, Qt::CaseInsensitive) == 0;
} }
bool CSandBoxPlus::IsFileDeleted(const QString& RealPath, const QString& Shapshot, const QStringList& SnapshotList, const QMap<QString, QList<QString>>& DeletedPaths) bool CSandBoxPlus::IsFileDeleted(const QString& RealPath, const QString& Snapshot, const QStringList& SnapshotList, const QMap<QString, QList<QString>>& DeletedPaths)
{ {
int NextIndex = SnapshotList.indexOf(Shapshot) - 1; int NextIndex = SnapshotList.indexOf(Snapshot) - 1;
if (NextIndex < 0) return false; // no newer snapshot if (NextIndex < 0) return false; // no newer snapshot
QString NewerSnapshot = SnapshotList.at(NextIndex); QString NewerSnapshot = SnapshotList.at(NextIndex);
@ -893,7 +893,7 @@ int CSandBoxPlus::IsLeaderProgram(const QString& ProgName)
return FindInStrList(Programs, ProgName) != Programs.end() ? 1 : 0; return FindInStrList(Programs, ProgName) != Programs.end() ? 1 : 0;
} }
SB_STATUS CSandBoxPlus::DeleteContentAsync(bool DeleteShapshots, bool bOnAutoDelete) SB_STATUS CSandBoxPlus::DeleteContentAsync(bool DeleteSnapshots, bool bOnAutoDelete)
{ {
if (GetBool("NeverDelete", false)) if (GetBool("NeverDelete", false))
return SB_ERR(SB_DeleteProtect); return SB_ERR(SB_DeleteProtect);
@ -908,7 +908,7 @@ SB_STATUS CSandBoxPlus::DeleteContentAsync(bool DeleteShapshots, bool bOnAutoDel
AddJobToQueue(pJob); AddJobToQueue(pJob);
} }
CBoxJob* pJob = new CCleanUpJob(this, DeleteShapshots, bOnAutoDelete); CBoxJob* pJob = new CCleanUpJob(this, DeleteSnapshots, bOnAutoDelete);
AddJobToQueue(pJob); AddJobToQueue(pJob);
return SB_OK; return SB_OK;

View File

@ -151,7 +151,7 @@ public:
bool IsOpen() const { return m_bRootAccessOpen; } bool IsOpen() const { return m_bRootAccessOpen; }
bool IsBusy() const { return IsSizePending() || !m_JobQueue.isEmpty(); } bool IsBusy() const { return IsSizePending() || !m_JobQueue.isEmpty(); }
SB_STATUS DeleteContentAsync(bool DeleteShapshots = true, bool bOnAutoDelete = false); SB_STATUS DeleteContentAsync(bool DeleteSnapshots = true, bool bOnAutoDelete = false);
struct SLink { struct SLink {
QString Folder; QString Folder;
@ -201,7 +201,7 @@ protected:
static void ExportBoxAsync(const CSbieProgressPtr& pProgress, const QString& ExportPath, const QString& RootPath, const QString& Section); static void ExportBoxAsync(const CSbieProgressPtr& pProgress, const QString& ExportPath, const QString& RootPath, const QString& Section);
static void ImportBoxAsync(const CSbieProgressPtr& pProgress, const QString& ImportPath, const QString& RootPath, const QString& BoxName); static void ImportBoxAsync(const CSbieProgressPtr& pProgress, const QString& ImportPath, const QString& RootPath, const QString& BoxName);
bool IsFileDeleted(const QString& RealPath, const QString& Shapshot, const QStringList& SnapshotList, const QMap<QString, QList<QString>>& DeletedPaths); bool IsFileDeleted(const QString& RealPath, const QString& Snapshot, const QStringList& SnapshotList, const QMap<QString, QList<QString>>& DeletedPaths);
QList<QSharedPointer<CBoxJob>> m_JobQueue; QList<QSharedPointer<CBoxJob>> m_JobQueue;

View File

@ -1317,7 +1317,7 @@ void CSbieView::OnSandBoxAction(QAction* Action, const QList<CSandBoxPtr>& SandB
} }
else if (Action == m_pMenuCleanUp) else if (Action == m_pMenuCleanUp)
{ {
bool DeleteShapshots = false; bool DeleteSnapshots = false;
if (SandBoxes.count() == 1) if (SandBoxes.count() == 1)
{ {
@ -1329,15 +1329,15 @@ void CSbieView::OnSandBoxAction(QAction* Action, const QList<CSandBoxPtr>& SandB
if (theConf->GetBool("Options/ShowRecovery", false)) if (theConf->GetBool("Options/ShowRecovery", false))
{ {
// Use recovery dialog in place of the confirmation messagebox for box clean up // Use recovery dialog in place of the confirmation messagebox for box clean up
if(!theGUI->OpenRecovery(SandBoxes.first(), DeleteShapshots)) if(!theGUI->OpenRecovery(SandBoxes.first(), DeleteSnapshots))
return; return;
} }
else if(CCheckableMessageBox::question(this, "Sandboxie-Plus", tr("Do you want to delete the content of the selected sandbox?") else if(CCheckableMessageBox::question(this, "Sandboxie-Plus", tr("Do you want to delete the content of the selected sandbox?")
, tr("Also delete all Snapshots"), &DeleteShapshots, QDialogButtonBox::Yes | QDialogButtonBox::No, QDialogButtonBox::Yes) != QDialogButtonBox::Yes) , tr("Also delete all Snapshots"), &DeleteSnapshots, QDialogButtonBox::Yes | QDialogButtonBox::No, QDialogButtonBox::Yes) != QDialogButtonBox::Yes)
return; return;
} }
else if(CCheckableMessageBox::question(this, "Sandboxie-Plus", tr("Do you really want to delete the content of all selected sandboxes?") else if(CCheckableMessageBox::question(this, "Sandboxie-Plus", tr("Do you really want to delete the content of all selected sandboxes?")
, tr("Also delete all Snapshots"), &DeleteShapshots, QDialogButtonBox::Yes | QDialogButtonBox::No, QDialogButtonBox::Yes) != QDialogButtonBox::Yes) , tr("Also delete all Snapshots"), &DeleteSnapshots, QDialogButtonBox::Yes | QDialogButtonBox::No, QDialogButtonBox::Yes) != QDialogButtonBox::Yes)
return; return;
foreach(const CSandBoxPtr &pBox, SandBoxes) foreach(const CSandBoxPtr &pBox, SandBoxes)
@ -1345,13 +1345,13 @@ void CSbieView::OnSandBoxAction(QAction* Action, const QList<CSandBoxPtr>& SandB
if (theConf->GetBool("Options/UseAsyncBoxOps", false) || theGUI->IsSilentMode()) if (theConf->GetBool("Options/UseAsyncBoxOps", false) || theGUI->IsSilentMode())
{ {
auto pBoxEx = pBox.objectCast<CSandBoxPlus>(); auto pBoxEx = pBox.objectCast<CSandBoxPlus>();
SB_STATUS Status = pBoxEx->DeleteContentAsync(DeleteShapshots); SB_STATUS Status = pBoxEx->DeleteContentAsync(DeleteSnapshots);
if (Status.IsError()) if (Status.IsError())
Results.append(Status); Results.append(Status);
} }
else else
{ {
SB_STATUS Status = theGUI->DeleteBoxContent(pBox, CSandMan::eDefault, DeleteShapshots); SB_STATUS Status = theGUI->DeleteBoxContent(pBox, CSandMan::eDefault, DeleteSnapshots);
if (Status.GetMsgCode() == SB_Canceled) if (Status.GetMsgCode() == SB_Canceled)
break; break;
Results.append(Status); Results.append(Status);

View File

@ -56,7 +56,7 @@ CRecoveryWindow::CRecoveryWindow(const CSandBoxPtr& pBox, bool bImmediate, QWidg
m_LastTargetIndex = 0; m_LastTargetIndex = 0;
m_bTargetsChanged = false; m_bTargetsChanged = false;
m_bReloadPending = false; m_bReloadPending = false;
m_DeleteShapshots = false; m_DeleteSnapshots = false;
QStyle* pStyle = QStyleFactory::create("windows"); QStyle* pStyle = QStyleFactory::create("windows");
ui.treeFiles->setStyle(pStyle); ui.treeFiles->setStyle(pStyle);
@ -259,7 +259,7 @@ void CRecoveryWindow::OnDeleteAll()
void CRecoveryWindow::OnDeleteEverything() void CRecoveryWindow::OnDeleteEverything()
{ {
m_DeleteShapshots = true; m_DeleteSnapshots = true;
OnDeleteAll(); OnDeleteAll();
} }

View File

@ -40,7 +40,7 @@ public:
~CRecoveryWindow(); ~CRecoveryWindow();
bool IsDeleteDialog() const; bool IsDeleteDialog() const;
bool IsDeleteShapshots() { return m_DeleteShapshots; } bool IsDeleteSnapshots() { return m_DeleteSnapshots; }
virtual void accept() {} virtual void accept() {}
virtual void reject() { this->close(); } virtual void reject() { this->close(); }
@ -94,7 +94,7 @@ protected:
int m_LastTargetIndex; int m_LastTargetIndex;
bool m_bTargetsChanged; bool m_bTargetsChanged;
bool m_bReloadPending; bool m_bReloadPending;
bool m_DeleteShapshots; bool m_DeleteSnapshots;
bool m_bImmediate; bool m_bImmediate;
private: private: