Various small fixes

This commit is contained in:
crschnick committed 2024-01-16 13:05:21 +00:00
1 parent dd54dccec7
commit bd2acc6574
9 files changed
+39 -25

No files matched your search

@@ -98,6 +98,11 @@ public class StoreEntryWrapper {
}
public void update() {
// We are probably in shutdown then
if (StoreViewState.get() == null) {
return;
}
// Avoid reupdating name when changed from the name property!
if (!entry.getName().equals(name.getValue())) {
name.setValue(entry.getName());
@@ -181,6 +181,7 @@ public class SentryErrorHandler implements ErrorHandler {
s.setTag("omitted", Boolean.toString(ee.isOmitted()));
s.setTag("diagnostics", Boolean.toString(ee.isShouldSendDiagnostics()));
s.setTag("logs", Boolean.toString(ee.isShouldSendDiagnostics() && !ee.getAttachments().isEmpty()));
s.setTag("inShutdown", Boolean.toString(OperationMode.isInShutdown()));
var exMessage = ee.getThrowable() != null ? ee.getThrowable().getMessage() : null;
if (ee.getDescription() != null && !ee.getDescription().equals(exMessage) && ee.isShouldSendDiagnostics()) {
@@ -38,9 +38,6 @@ public abstract class DataStorage {
@Getter
protected boolean loaded;
@Getter
protected boolean disposed;
@Getter
protected final List<DataStoreCategory> storeCategories;
@@ -115,8 +112,7 @@ public abstract class DataStorage {
private synchronized void dispose() {
onReset();
save();
disposed = true;
save(true);
}
protected void onReset() {}
@@ -156,11 +152,11 @@ public abstract class DataStorage {
}
ThreadHelper.runAsync(() -> {
save();
save(false);
});
}
public abstract void save();
public abstract void save(boolean dispose);
public abstract boolean supportsSharing();
public boolean shouldShare(DataStoreCategory entry) {
@@ -18,7 +18,7 @@ public class ImpersistentStorage extends DataStorage {
}
@Override
public void save() {
public void save(boolean dispose) {
var storesDir = getStoresDir();
TrackEvent.info("Storage persistence is disabled. Deleting storage contents ...");
@@ -25,6 +25,9 @@ public class StandardStorage extends DataStorage {
@Getter
private final GitStorageHandler gitStorageHandler;
@Getter
private boolean disposed;
StandardStorage() {
this.gitStorageHandler = GitStorageHandler.getInstance();
this.gitStorageHandler.init(dir);
@@ -119,10 +122,12 @@ public class StandardStorage extends DataStorage {
var storesDir = getStoresDir();
var categoriesDir = getCategoriesDir();
var dataDir = getDataDir();
try {
FileUtils.forceMkdir(storesDir.toFile());
FileUtils.forceMkdir(categoriesDir.toFile());
FileUtils.forceMkdir(dataDir.toFile());
} catch (Exception e) {
ErrorEvent.fromThrowable(e).terminal(true).build().handle();
}
@@ -292,7 +297,7 @@ public class StandardStorage extends DataStorage {
entry.dirty = true;
entry.setStoreNode(DataStorageWriter.storeToNode(entry.getStore()));
});
save();
save(false);
}
deleteLeftovers();
@@ -302,7 +307,7 @@ public class StandardStorage extends DataStorage {
this.gitStorageHandler.afterStorageLoad();
}
public void save() {
public void save(boolean dispose) {
if (!loaded || disposed) {
return;
}
@@ -363,6 +368,9 @@ public class StandardStorage extends DataStorage {
deleteLeftovers();
gitStorageHandler.afterStorageSave();
if (dispose) {
disposed = true;
}
busyIo.unlock();
}
@@ -27,10 +27,10 @@ public enum PlatformState {
public static void teardown() {
PlatformThread.runLaterIfNeededBlocking(() -> {
// Fix to preserve clipboard contents after shutdown
var string = Clipboard.getSystemClipboard().getString();
var s = new StringSelection(string);
try {
// Fix to preserve clipboard contents after shutdown
var string = Clipboard.getSystemClipboard().getString();
var s = new StringSelection(string);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(s, s);
} catch (IllegalStateException ignored) {
}