Skip to content

Commit

Permalink
delete or just unlink?
Browse files Browse the repository at this point in the history
Orthanc Rest API/GUI "delete study/instance" button should really delete
from camicroscope or make invisible until orthanc restart?
  • Loading branch information
CGDogan committed Sep 18, 2023
1 parent 51aa851 commit 9ace36a
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/Sources/Plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,32 @@ static OrthancPluginErrorCode StorageRemove(const char *uuid,
{
__builtin_printf("StorageRemove br1 %s\n", uuid);
database_.RemoveAttachment(uuid);

// Deleting from Orthanc UI/API should really delete the file or just make it invisible
// from Orthanc until restart? If the latter, please comment out the next few lines until end of "if" true branch:

// Count the number of times a file is recorded as attachment (a file registered with how many UUIDs)
std::string instanceId;
database_.LookupFile(instanceId, externalPath, 0, 0);
int64_t times;
database_.CountTimesAttached(times, instanceId);

if (times == 0) {
// Delete the file
boost::filesystem::path boostPath(externalPath);
if (boost::filesystem::exists(boostPath))
{
try {
// Small race condition here for the next two lines, they should execute as one statement
boost::filesystem::remove(boostPath);
database_.RemoveFile(externalPath);
} catch(...) {
fprintf(stderr, "file removal failed for %s\n", externalPath.c_str());
}
}
camic_notifier::notify("/fs/deletedFile?filepath=" + camic_notifier::escape(boostPath.lexically_relative(realStoragePath).string()));
database_.RemoveFile(externalPath);
}
}
else
{
Expand Down

0 comments on commit 9ace36a

Please sign in to comment.