Small fixes

This commit is contained in:
crschnick 2024-01-18 17:15:35 +00:00
parent f467d59f49
commit 46cd57db18
4 changed files with 8 additions and 48 deletions

View file

@ -4,7 +4,6 @@ import io.xpipe.app.comp.store.StoreSortMode;
import io.xpipe.app.issue.ErrorEvent; import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.TrackEvent; import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.prefs.AppPrefs; import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.util.XPipeSession;
import io.xpipe.core.store.LocalStore; import io.xpipe.core.store.LocalStore;
import lombok.Getter; import lombok.Getter;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
@ -38,10 +37,6 @@ public class StandardStorage extends DataStorage {
gitStorageHandler.onReset(); gitStorageHandler.onReset();
} }
private boolean isNewSession() {
return XPipeSession.get().isNewSystemSession();
}
private void deleteLeftovers() { private void deleteLeftovers() {
var storesDir = getStoresDir(); var storesDir = getStoresDir();
var categoriesDir = getCategoriesDir(); var categoriesDir = getCategoriesDir();

View file

@ -1,21 +1,13 @@
package io.xpipe.app.util; package io.xpipe.app.util;
import io.xpipe.app.core.AppCache; import io.xpipe.app.core.AppCache;
import io.xpipe.app.core.AppProperties;
import io.xpipe.core.process.OsType;
import io.xpipe.core.util.UuidHelper;
import lombok.Value; import lombok.Value;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.UUID; import java.util.UUID;
@Value @Value
public class XPipeSession { public class XPipeSession {
boolean isNewSystemSession;
boolean isNewBuildSession; boolean isNewBuildSession;
/** /**
@ -28,10 +20,6 @@ public class XPipeSession {
*/ */
UUID buildSessionId; UUID buildSessionId;
/**
* Unique identifier that resets on system restarts.
*/
UUID systemSessionId;
private static XPipeSession INSTANCE; private static XPipeSession INSTANCE;
@ -40,38 +28,10 @@ public class XPipeSession {
return; return;
} }
var sessionFile = Path.of(System.getProperty("java.io.tmpdir")).resolve("xpipe_session"); var s = AppCache.get("lastBuildId", String.class, () -> null);
var isNewSystemSession = !Files.exists(sessionFile);
var systemSessionId = isNewSystemSession
? UUID.randomUUID()
: UuidHelper.parse(() -> Files.readString(sessionFile)).orElse(UUID.randomUUID());
try {
// TODO: People might move their page file to another drive
if (OsType.getLocal().equals(OsType.WINDOWS)) {
var pf = Path.of("C:\\pagefile.sys");
BasicFileAttributes attr = Files.readAttributes(pf, BasicFileAttributes.class);
var timeUuid = UUID.nameUUIDFromBytes(
attr.creationTime().toInstant().toString().getBytes());
isNewSystemSession = isNewSystemSession && timeUuid.equals(systemSessionId);
systemSessionId = timeUuid;
}
} catch (Exception ex) {
isNewSystemSession = true;
systemSessionId = UUID.randomUUID();
}
try {
Files.writeString(sessionFile, systemSessionId.toString());
} catch (Exception ignored) {
}
var s = AppCache.get("lastBuild", String.class, () -> buildSessionId.toString());
var isBuildChanged = !buildSessionId.toString().equals(s); var isBuildChanged = !buildSessionId.toString().equals(s);
AppCache.update("lastBuild", AppProperties.get().getVersion()); AppCache.update("lastBuildId", buildSessionId.toString());
INSTANCE = new XPipeSession(isBuildChanged, UUID.randomUUID(), buildSessionId);
INSTANCE = new XPipeSession(
isNewSystemSession, isBuildChanged, UUID.randomUUID(), buildSessionId, systemSessionId);
} }
public static XPipeSession get() { public static XPipeSession get() {

View file

@ -142,6 +142,7 @@ cmd=cmd.exe
powershell=Powershell powershell=Powershell
pwsh=Powershell Core pwsh=Powershell Core
windowsTerminal=Windows Terminal windowsTerminal=Windows Terminal
windowsTerminalPreview=Windows Terminal Preview
gnomeTerminal=Gnome Terminal gnomeTerminal=Gnome Terminal
createLock=Create lock createLock=Create lock
tilix=Tilix tilix=Tilix

4
dist/build.gradle vendored
View file

@ -38,6 +38,10 @@ task createChecksums(type: Checksum) {
doLast { doLast {
def artifactChecksumsSha256Hex = new HashMap<String, String>() def artifactChecksumsSha256Hex = new HashMap<String, String>()
for (final def file in outputDirectory.get().getAsFileTree().files) { for (final def file in outputDirectory.get().getAsFileTree().files) {
if (file.toString().endsWith('mapping.map')) {
continue
}
def name = file.name.lastIndexOf('.').with {it != -1 ? file.name[0..<it] : file.name} def name = file.name.lastIndexOf('.').with {it != -1 ? file.name[0..<it] : file.name}
artifactChecksumsSha256Hex.put(name, file.text.trim()) artifactChecksumsSha256Hex.put(name, file.text.trim())
} }