mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[settingsSync] return actual pushedVersion during sendSnapshotFile()
GitOrigin-RevId: 979cb8d84aaffa51f7e5a8c43f1e599d855ba6ba
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a18e8eaf01
commit
32efef3866
+23
-24
@@ -116,38 +116,37 @@ abstract class AbstractServerCommunicator() : SettingsSyncRemoteCommunicator {
|
||||
val defaultMessage = "Unknown during checking $CROSS_IDE_SYNC_MARKER_FILE"
|
||||
try {
|
||||
snapshotFilePath = currentSnapshotFilePath()?.first ?: return SettingsSyncPushResult.Error(defaultMessage)
|
||||
}
|
||||
catch (ioe: IOException) {
|
||||
return SettingsSyncPushResult.Error(ioe.message ?: defaultMessage)
|
||||
}
|
||||
|
||||
val versionToPush: String?
|
||||
if (force) {
|
||||
// get the latest server version: pushing with it will overwrite the file in any case
|
||||
versionToPush = getLatestVersion(snapshotFilePath)
|
||||
writeFileInternal(snapshotFilePath, versionToPush, inputStream)
|
||||
}
|
||||
else {
|
||||
if (knownServerVersion != null) {
|
||||
versionToPush = knownServerVersion
|
||||
val versionToPush: String?
|
||||
if (force) {
|
||||
// get the latest server version: pushing with it will overwrite the file in any case
|
||||
versionToPush = getLatestVersion(snapshotFilePath)
|
||||
}
|
||||
else {
|
||||
val serverVersion = getLatestVersion(snapshotFilePath)
|
||||
if (serverVersion == null) {
|
||||
// no file on the server => just push it there
|
||||
versionToPush = null
|
||||
if (knownServerVersion != null) {
|
||||
versionToPush = knownServerVersion
|
||||
}
|
||||
else {
|
||||
// we didn't store the server version locally yet => reject the push to avoid overwriting the server version;
|
||||
// the next update after the rejected push will store the version information, and subsequent push will be successful.
|
||||
return SettingsSyncPushResult.Rejected
|
||||
val serverVersion = getLatestVersion(snapshotFilePath)
|
||||
if (serverVersion == null) {
|
||||
// no file on the server => just push it there
|
||||
versionToPush = null
|
||||
}
|
||||
else {
|
||||
// we didn't store the server version locally yet => reject the push to avoid overwriting the server version;
|
||||
// the next update after the rejected push will store the version information, and subsequent push will be successful.
|
||||
return SettingsSyncPushResult.Rejected
|
||||
}
|
||||
}
|
||||
}
|
||||
writeFileInternal(snapshotFilePath, versionToPush, inputStream)
|
||||
}
|
||||
|
||||
// errors are thrown as exceptions, and are handled above
|
||||
return SettingsSyncPushResult.Success(versionToPush)
|
||||
val pushedVersion = writeFileInternal(snapshotFilePath, versionToPush, inputStream)
|
||||
// errors are thrown as exceptions, and are handled above
|
||||
return SettingsSyncPushResult.Success(pushedVersion)
|
||||
}
|
||||
catch (e: Throwable) {
|
||||
return SettingsSyncPushResult.Error(e.message ?: defaultMessage)
|
||||
}
|
||||
}
|
||||
|
||||
override fun checkServerState(): ServerState {
|
||||
|
||||
Reference in New Issue
Block a user