mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-25 00:50:31 +00:00
Small fixes
This commit is contained in:
parent
f467d59f49
commit
46cd57db18
4 changed files with 8 additions and 48 deletions
|
@ -4,7 +4,6 @@ import io.xpipe.app.comp.store.StoreSortMode;
|
|||
import io.xpipe.app.issue.ErrorEvent;
|
||||
import io.xpipe.app.issue.TrackEvent;
|
||||
import io.xpipe.app.prefs.AppPrefs;
|
||||
import io.xpipe.app.util.XPipeSession;
|
||||
import io.xpipe.core.store.LocalStore;
|
||||
import lombok.Getter;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
@ -38,10 +37,6 @@ public class StandardStorage extends DataStorage {
|
|||
gitStorageHandler.onReset();
|
||||
}
|
||||
|
||||
private boolean isNewSession() {
|
||||
return XPipeSession.get().isNewSystemSession();
|
||||
}
|
||||
|
||||
private void deleteLeftovers() {
|
||||
var storesDir = getStoresDir();
|
||||
var categoriesDir = getCategoriesDir();
|
||||
|
|
|
@ -1,21 +1,13 @@
|
|||
package io.xpipe.app.util;
|
||||
|
||||
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 java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.UUID;
|
||||
|
||||
@Value
|
||||
public class XPipeSession {
|
||||
|
||||
boolean isNewSystemSession;
|
||||
|
||||
boolean isNewBuildSession;
|
||||
|
||||
/**
|
||||
|
@ -28,10 +20,6 @@ public class XPipeSession {
|
|||
*/
|
||||
UUID buildSessionId;
|
||||
|
||||
/**
|
||||
* Unique identifier that resets on system restarts.
|
||||
*/
|
||||
UUID systemSessionId;
|
||||
|
||||
private static XPipeSession INSTANCE;
|
||||
|
||||
|
@ -40,38 +28,10 @@ public class XPipeSession {
|
|||
return;
|
||||
}
|
||||
|
||||
var sessionFile = Path.of(System.getProperty("java.io.tmpdir")).resolve("xpipe_session");
|
||||
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 s = AppCache.get("lastBuildId", String.class, () -> null);
|
||||
var isBuildChanged = !buildSessionId.toString().equals(s);
|
||||
AppCache.update("lastBuild", AppProperties.get().getVersion());
|
||||
|
||||
INSTANCE = new XPipeSession(
|
||||
isNewSystemSession, isBuildChanged, UUID.randomUUID(), buildSessionId, systemSessionId);
|
||||
AppCache.update("lastBuildId", buildSessionId.toString());
|
||||
INSTANCE = new XPipeSession(isBuildChanged, UUID.randomUUID(), buildSessionId);
|
||||
}
|
||||
|
||||
public static XPipeSession get() {
|
||||
|
|
|
@ -142,6 +142,7 @@ cmd=cmd.exe
|
|||
powershell=Powershell
|
||||
pwsh=Powershell Core
|
||||
windowsTerminal=Windows Terminal
|
||||
windowsTerminalPreview=Windows Terminal Preview
|
||||
gnomeTerminal=Gnome Terminal
|
||||
createLock=Create lock
|
||||
tilix=Tilix
|
||||
|
|
4
dist/build.gradle
vendored
4
dist/build.gradle
vendored
|
@ -38,6 +38,10 @@ task createChecksums(type: Checksum) {
|
|||
doLast {
|
||||
def artifactChecksumsSha256Hex = new HashMap<String, String>()
|
||||
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}
|
||||
artifactChecksumsSha256Hex.put(name, file.text.trim())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue