diff --git a/app/src/main/java/io/xpipe/app/comp/store/StoreCategoryWrapper.java b/app/src/main/java/io/xpipe/app/comp/store/StoreCategoryWrapper.java index 621c0a29d..1803ad617 100644 --- a/app/src/main/java/io/xpipe/app/comp/store/StoreCategoryWrapper.java +++ b/app/src/main/java/io/xpipe/app/comp/store/StoreCategoryWrapper.java @@ -26,7 +26,7 @@ public class StoreCategoryWrapper { private final DataStoreCategory category; private final Property lastAccess; private final Property sortMode; - private final Property share; + private final Property sync; private final ObservableList children; private final ObservableList containedEntries; private final BooleanProperty expanded = new SimpleBooleanProperty(); @@ -50,7 +50,7 @@ public class StoreCategoryWrapper { this.name = new SimpleStringProperty(category.getName()); this.lastAccess = new SimpleObjectProperty<>(category.getLastAccess()); this.sortMode = new SimpleObjectProperty<>(category.getSortMode()); - this.share = new SimpleObjectProperty<>(category.isShare()); + this.sync = new SimpleObjectProperty<>(category.isSync()); this.children = FXCollections.observableArrayList(); this.containedEntries = FXCollections.observableArrayList(); this.color.setValue(category.getColor()); @@ -108,8 +108,8 @@ public class StoreCategoryWrapper { category.setSortMode(newValue); }); - share.addListener((observable, oldValue, newValue) -> { - DataStorage.get().shareCategory(category, newValue); + sync.addListener((observable, oldValue, newValue) -> { + DataStorage.get().syncCategory(category, newValue); }); } @@ -131,7 +131,7 @@ public class StoreCategoryWrapper { lastAccess.setValue(category.getLastAccess().minus(Duration.ofMillis(500))); sortMode.setValue(category.getSortMode()); - share.setValue(category.isShare()); + sync.setValue(category.isSync()); expanded.setValue(category.isExpanded()); color.setValue(category.getColor()); diff --git a/app/src/main/java/io/xpipe/app/core/mode/BaseMode.java b/app/src/main/java/io/xpipe/app/core/mode/BaseMode.java index ae4d3bac6..6f2f66585 100644 --- a/app/src/main/java/io/xpipe/app/core/mode/BaseMode.java +++ b/app/src/main/java/io/xpipe/app/core/mode/BaseMode.java @@ -14,7 +14,7 @@ import io.xpipe.app.ext.DataStoreProviders; import io.xpipe.app.issue.TrackEvent; import io.xpipe.app.prefs.AppPrefs; import io.xpipe.app.storage.DataStorage; -import io.xpipe.app.storage.GitStorageHandler; +import io.xpipe.app.storage.DataStorageSyncHandler; import io.xpipe.app.update.XPipeDistributionType; import io.xpipe.app.util.*; @@ -54,8 +54,8 @@ public class BaseMode extends OperationMode { AppPrefs.setLocalDefaultsIfNeeded(); // Initialize beacon server as we should be prepared for git askpass commands AppBeaconServer.init(); - GitStorageHandler.getInstance().init(); - GitStorageHandler.getInstance().setupRepositoryAndPull(); + DataStorageSyncHandler.getInstance().init(); + DataStorageSyncHandler.getInstance().retrieveSyncedData(); AppPrefs.initSharedRemote(); UnlockAlert.showIfNeeded(); DataStorage.init(); diff --git a/app/src/main/java/io/xpipe/app/fxcomps/impl/StoreCategoryComp.java b/app/src/main/java/io/xpipe/app/fxcomps/impl/StoreCategoryComp.java index 9480e2165..3f92aae3a 100644 --- a/app/src/main/java/io/xpipe/app/fxcomps/impl/StoreCategoryComp.java +++ b/app/src/main/java/io/xpipe/app/fxcomps/impl/StoreCategoryComp.java @@ -89,9 +89,9 @@ public class StoreCategoryComp extends SimpleComp { return "mdi2a-account-lock"; } - return category.getShare().getValue() ? "mdi2g-git" : "mdi2a-account-cancel"; + return category.getSync().getValue() ? "mdi2g-git" : "mdi2a-account-cancel"; }, - category.getShare(), + category.getSync(), hover); var statusButton = new IconButtonComp(statusIcon) .apply(struc -> AppFont.small(struc.get())) @@ -217,25 +217,25 @@ public class StoreCategoryComp extends SimpleComp { share.textProperty() .bind(Bindings.createStringBinding( () -> { - if (category.getShare().getValue()) { + if (category.getSync().getValue()) { return AppI18n.get("unshare"); } else { return AppI18n.get("share"); } }, - category.getShare())); + category.getSync())); share.graphicProperty() .bind(Bindings.createObjectBinding( () -> { - if (category.getShare().getValue()) { + if (category.getSync().getValue()) { return new FontIcon("mdi2b-block-helper"); } else { return new FontIcon("mdi2g-git"); } }, - category.getShare())); + category.getSync())); share.setOnAction(event -> { - category.getShare().setValue(!category.getShare().getValue()); + category.getSync().setValue(!category.getSync().getValue()); }); contextMenu.getItems().add(share); } diff --git a/app/src/main/java/io/xpipe/app/storage/DataStorage.java b/app/src/main/java/io/xpipe/app/storage/DataStorage.java index affdefaca..b3b45f1da 100644 --- a/app/src/main/java/io/xpipe/app/storage/DataStorage.java +++ b/app/src/main/java/io/xpipe/app/storage/DataStorage.java @@ -315,8 +315,8 @@ public abstract class DataStorage { saveAsync(); } - public void shareCategory(DataStoreCategory category, boolean share) { - category.setShare(share); + public void syncCategory(DataStoreCategory category, boolean share) { + category.setSync(share); DataStoreCategory p = category; if (share) { @@ -324,7 +324,7 @@ public abstract class DataStorage { .getStoreCategoryIfPresent(p.getParentCategory()) .orElse(null)) != null) { - p.setShare(true); + p.setSync(true); } } diff --git a/app/src/main/java/io/xpipe/app/storage/GitStorageHandler.java b/app/src/main/java/io/xpipe/app/storage/DataStorageSyncHandler.java similarity index 64% rename from app/src/main/java/io/xpipe/app/storage/GitStorageHandler.java rename to app/src/main/java/io/xpipe/app/storage/DataStorageSyncHandler.java index 3b02096e4..5ea256481 100644 --- a/app/src/main/java/io/xpipe/app/storage/GitStorageHandler.java +++ b/app/src/main/java/io/xpipe/app/storage/DataStorageSyncHandler.java @@ -4,17 +4,17 @@ import io.xpipe.core.process.ProcessControlProvider; import java.nio.file.Path; -public interface GitStorageHandler { +public interface DataStorageSyncHandler { - static GitStorageHandler getInstance() { - return (GitStorageHandler) ProcessControlProvider.get().getGitStorageHandler(); + static DataStorageSyncHandler getInstance() { + return (DataStorageSyncHandler) ProcessControlProvider.get().getGitStorageHandler(); } - boolean supportsShare(); + boolean supportsSync(); void init(); - void setupRepositoryAndPull(); + void retrieveSyncedData(); void afterStorageLoad(); diff --git a/app/src/main/java/io/xpipe/app/storage/DataStoreCategory.java b/app/src/main/java/io/xpipe/app/storage/DataStoreCategory.java index 610b183e1..1b8d2377a 100644 --- a/app/src/main/java/io/xpipe/app/storage/DataStoreCategory.java +++ b/app/src/main/java/io/xpipe/app/storage/DataStoreCategory.java @@ -31,7 +31,7 @@ public class DataStoreCategory extends StorageElement { StoreSortMode sortMode; @NonFinal - boolean share; + boolean sync; public DataStoreCategory( Path directory, @@ -43,12 +43,12 @@ public class DataStoreCategory extends StorageElement { boolean dirty, UUID parentCategory, StoreSortMode sortMode, - boolean share, + boolean sync, boolean expanded) { super(directory, uuid, name, lastUsed, lastModified, color, expanded, dirty); this.parentCategory = parentCategory; this.sortMode = sortMode; - this.share = share; + this.sync = sync; } public static DataStoreCategory createNew(UUID parentCategory, @NonNull String name) { @@ -140,10 +140,10 @@ public class DataStoreCategory extends StorageElement { } } - public void setShare(boolean newShare) { - var changed = share != newShare; + public void setSync(boolean newShare) { + var changed = sync != newShare; if (changed) { - this.share = newShare; + this.sync = newShare; notifyUpdate(false, true); } } @@ -174,7 +174,7 @@ public class DataStoreCategory extends StorageElement { return false; } - return isShare(); + return isSync(); } @Override @@ -192,7 +192,7 @@ public class DataStoreCategory extends StorageElement { ObjectNode stateObj = JsonNodeFactory.instance.objectNode(); obj.put("uuid", uuid.toString()); obj.put("name", name); - obj.put("share", share); + obj.put("share", sync); obj.set("color", mapper.valueToTree(color)); stateObj.put("lastUsed", lastUsed.toString()); stateObj.put("lastModified", lastModified.toString()); diff --git a/app/src/main/java/io/xpipe/app/storage/StandardStorage.java b/app/src/main/java/io/xpipe/app/storage/StandardStorage.java index b4f85473e..dfa1108d1 100644 --- a/app/src/main/java/io/xpipe/app/storage/StandardStorage.java +++ b/app/src/main/java/io/xpipe/app/storage/StandardStorage.java @@ -29,7 +29,7 @@ public class StandardStorage extends DataStorage { private final List directoriesToKeep = new ArrayList<>(); @Getter - private final GitStorageHandler gitStorageHandler; + private final DataStorageSyncHandler dataStorageSyncHandler; private String vaultKey; @@ -37,7 +37,7 @@ public class StandardStorage extends DataStorage { private boolean disposed; StandardStorage() { - this.gitStorageHandler = GitStorageHandler.getInstance(); + this.dataStorageSyncHandler = DataStorageSyncHandler.getInstance(); } @Override @@ -263,7 +263,7 @@ public class StandardStorage extends DataStorage { loaded = true; busyIo.unlock(); - this.gitStorageHandler.afterStorageLoad(); + this.dataStorageSyncHandler.afterStorageLoad(); } private void callProviders() { @@ -297,7 +297,7 @@ public class StandardStorage extends DataStorage { return; } - this.gitStorageHandler.beforeStorageSave(); + this.dataStorageSyncHandler.beforeStorageSave(); try { FileUtils.forceMkdir(getStoresDir().toFile()); @@ -317,7 +317,7 @@ public class StandardStorage extends DataStorage { var exists = Files.exists(e.getDirectory()); var dirty = e.isDirty(); e.writeDataToDisk(); - gitStorageHandler.handleCategory(e, exists, dirty); + dataStorageSyncHandler.handleCategory(e, exists, dirty); } catch (IOException ex) { // IO exceptions are not expected exception.set(ex); @@ -334,7 +334,7 @@ public class StandardStorage extends DataStorage { var exists = Files.exists(e.getDirectory()); var dirty = e.isDirty(); e.writeDataToDisk(); - gitStorageHandler.handleEntry(e, exists, dirty); + dataStorageSyncHandler.handleEntry(e, exists, dirty); } catch (Exception ex) { // Data corruption and schema changes are expected exception.set(ex); @@ -348,7 +348,7 @@ public class StandardStorage extends DataStorage { } deleteLeftovers(); - gitStorageHandler.afterStorageSave(); + dataStorageSyncHandler.afterStorageSave(); if (dispose) { disposed = true; } @@ -357,7 +357,7 @@ public class StandardStorage extends DataStorage { @Override public boolean supportsSharing() { - return gitStorageHandler.supportsShare(); + return dataStorageSyncHandler.supportsSync(); } private void deleteLeftovers() { @@ -387,7 +387,7 @@ public class StandardStorage extends DataStorage { .tag("uuid", uuid) .handle(); FileUtils.forceDelete(file.toFile()); - gitStorageHandler.handleDeletion(file, uuid.toString()); + dataStorageSyncHandler.handleDeletion(file, uuid.toString()); } } catch (Exception ex) { ErrorEvent.fromThrowable(ex).expected().omit().build().handle(); @@ -420,7 +420,7 @@ public class StandardStorage extends DataStorage { .tag("uuid", uuid) .handle(); FileUtils.forceDelete(file.toFile()); - gitStorageHandler.handleDeletion(file, uuid.toString()); + dataStorageSyncHandler.handleDeletion(file, uuid.toString()); } } catch (Exception ex) { ErrorEvent.fromThrowable(ex).expected().omit().build().handle();