Class sh::filesystem::Operation

class sh::filesystem::Operation : public QObject

A operation surrounds a completed series of steps in the filesystem.

For some steps to execute in the filesystem (i.e. not only the local one but the entire Eurl universe), it fetches intermediate files, caches them and writes them back to their real location afterwards.

It provides transaction-like operations for committing/dropping those intermediate files. A high-level interface for file management is avaiable in filesystem.

It is allowed to create new instances from scratch, but you should check if you implicitely have an instance available in your situation, or if sh::tools::OperationsCache is an option.

Public Functions

Operation(QObject *parent = 0)

Often constructed by the infrastructure and made available, but can also be constructed directly.

quint64 getFreeCacheSpace()

Returns the free disk space (in bytes) available for operations like fetchContainerFile() or fetchFile().

QString fetchContainerFile(std::shared_ptr<const sh::filesystem::Eurl> eurl, QString namehint)

Fetches the container file for a eurl locally and returns the local path. Use this with care and only if needed. In many cases working with streams is the better way!

QString fetchContainerFile(std::shared_ptr<const sh::filesystem::Eurl> eurl)
QString fetchFile(std::shared_ptr<const sh::filesystem::Eurl> eurl, QString namehint)

Fetches a file locally and returns the local path. Use this with care and only if needed. In many cases working with streams is the better way!

QString fetchFile(std::shared_ptr<const sh::filesystem::Eurl> eurl)
void abort()

Aborts transaction dropping all pending changes.

void commit()

Commits transaction applying all pending changes.

void enableDetailsCache()

Enable details caching.

bool isDetailsCacheEnabled()

Is details caching enabled?

void storeDetailInCache(std::shared_ptr<const sh::filesystem::Eurl> eurl, sh::filesystem::DetailColumn *column, QVariant value)

Stores a column detail in cache.

QVariant getDetailFromCache(std::shared_ptr<const sh::filesystem::Eurl> eurl, const sh::filesystem::DetailColumn *column)

Gets a column value from cache.

QList<std::shared_ptr<const sh::filesystem::Eurl>> pendingCommits()

Returns a list of sh::filesystem::Eurl items which are marked for commit.

QString getTempDir()

Creates a fresh temporary folder and returns the path to it.

void setCustomData(std::shared_ptr<const sh::filesystem::Eurl> eurl, QString key, QVariant data)

Stores custom data.

QVariant getCustomData(std::shared_ptr<const sh::filesystem::Eurl> eurl, QString key)

Gets stored custom data.

void setMaxAllowedSizeRatioPerPart(double v)

Sets a maximum part of available disk space for usage. This is exotic functionality you typically don’t need. .

Parameters
  • v: A ratio (between 0 and 1) of the available disk space which one part maximally may cost.

sh::filesystem::FilesystemOperation *filesystem()

Gets the sh::filesystem::FilesystemOperation filesystem operation object.

~Operation()

Public Static Functions

void writeIODeviceToFile(QIODevice *content, QString filepath)

Low-level function for writing a QIODevice content to a local path.

Private Members

QHash<std::shared_ptr<const sh::filesystem::Eurl>, QString> files
QSet<std::shared_ptr<const sh::filesystem::Eurl>> fileIsTemporary
QList<QString> tempDirs
bool _detailsCacheEnabled = false
QHash<std::shared_ptr<const sh::filesystem::Eurl>, QMap<QString, QVariant>> _customData
QHash<const sh::filesystem::DetailColumn*, QHash<std::shared_ptr<const sh::filesystem::Eurl>, QVariant>> _detailsCache
sh::filesystem::FilesystemOperation *_filesystemOperation
double _maxAllowedSizeRatioPerPart
QMutex operationlock

Private Static Attributes

QMutex _tempfilemutex
QString _tempdir
class MaxAllowedSizeRatioPerPartExceededException : public sh::exceptions::IOException

IO exception raised when the value in setMaxAllowedSizeRatioPerPart() was exceeded.

Public Functions

MaxAllowedSizeRatioPerPartExceededException()
QString message() const
QString name() const
QString classes() const
QString details() const
QString callstack() const
QString auxiliary() const
QString customValue(QString key) const
bool isRuntimeException() const
bool isProgramException() const
bool isRetryable() const
bool isResumeable() const
bool isDetailsAreInteresting() const
int autoRetryRecommendedIn() const
void setResumeable(bool v)
void setReTryable(bool v)
void setCustomValue(QString key, QString value)
bool isClass(QString classname)
sh::exceptions::ExceptionData data()

Public Static Functions

template<class Handler>
std::shared_ptr<RegisterHandler<Handler>> createRegisterHandler(Handler handler, QStack<Handler> *stack)
void executeGuarded(std::function<void()> fctint flags = 0, )

Executes some code with some standard exection handling around.

Parameters
  • fct: The code to execute guarded.

  • flags: Flags of ExecuteGuardFlag for choosing the behavior.

void executeGuarded_errorpanel(std::function<void()> fctint flags = 0, )
QString _demangle(QString l)
void exceptionDialog(sh::exceptions::Exception &e, bool *doRetry)

Public Static Attributes

const QString UNDEFINED_ERROR_OCCURRED = QObject::tr("An unspecified error occurred.")
const QString SHALLOT_MUST_CLOSE_TEXT = QObject::tr("Your Shallot process is disturbed by an error and needs to be closed now. You can try if starting Shallot again solves the issue. If you are interested in technical details, please take a look at the log.")
const QString Value_isShallotException = "_isShallotException"