MCPcopy Create free account
hub / github.com/LibrePCB/LibrePCB / getRelativeFilePath

Method getRelativeFilePath

libs/librepcb/core/project/projectloader.cpp:120–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118</html>)";
119
120QString ProjectLoader::MigrationLog::getRelativeFilePath(
121 bool isTemporary) const noexcept {
122 if (isTemporary) {
123 // Important: Don't store the HTML in /tmp or ~/.cache because if LibrePCB
124 // runs in a sandbox, other apps may not have access to read those
125 // directories. In addition, even though the cache directory is globally
126 // readable by Snap and Flatpak applications, the Firefox and Chromium Snaps
127 // reject to open HTML files from those places. See:
128 // * https://bugs.launchpad.net/snapd/+bug/1972762
129 // * https://askubuntu.com/questions/1370653/snap-apps-dont-find-files-in-tmp
130 // * https://librepcb.discourse.group/t/unable-to-see-messages-from-file-format-upgrade/1036.
131 // So we store the HTML in the project directory instead, but schedule it
132 // for deletion once the project is saved (leading to a new, final migration
133 // log).
134 //
135 // Using a deterministic file name, not containing the date or file format.
136 // This is important because the temporary file may be created today with
137 // LibrePCB 1.x, but will get deleted in a year with LibrePCB 2.x, so the
138 // file name shall not change between those sessions.
139 return "logs/migration_preview.html";
140 } else {
141 return QString("logs/%1_migration_to_v%2.html")
142 .arg(dateTime.date().toString("yyyy-MM-dd"),
143 Application::getFileFormatVersion().toStr());
144 }
145}
146
147QByteArray ProjectLoader::MigrationLog::toHtml(
148 bool isTemporary) const noexcept {

Callers 2

openMethod · 0.80
openMigrationLogMethod · 0.80

Calls 3

QStringClass · 0.85
toStringMethod · 0.45
toStrMethod · 0.45

Tested by

no test coverage detected