[settingsSync] return actual pushedVersion during sendSnapshotFile()

GitOrigin-RevId: 979cb8d84aaffa51f7e5a8c43f1e599d855ba6ba
This commit is contained in:
Sergey Pak
2025-04-08 23:46:40 +00:00
committed by intellij-monorepo-bot
parent a18e8eaf01
commit 32efef3866
@@ -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 {