mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
[remote dev] don't report an internal error if a configuration file cannot be loaded from a shared config folder (IJPL-183372, IJPL-191825)
Instead, fire a notification like it's done in FileBasedStorage when loading in a regular IDE. GitOrigin-RevId: 791c710bb0e6ec6a414a809c5af28ac49ad21dd1
This commit is contained in:
committed by
intellij-monorepo-bot
parent
48351b9e5e
commit
ae2cf320c2
@@ -191,6 +191,9 @@ notification.glibc.is.not.supported.text=Your system is running Linux with a gli
|
||||
To ensure you can always use the latest version of {1}, we recommend upgrading your operating system.
|
||||
notification.glibc.is.not.supported.button=Read more
|
||||
|
||||
notification.cannot.load.settings.title=Cannot load settings
|
||||
notification.cannot.load.settings.content=Cannot load settings from file ''{0}'': {1}.
|
||||
|
||||
notification.content.there.no.such.file=There is no such file: {0}
|
||||
action.open.folder.text=Open Folder
|
||||
action.open.folder.description=Open Folder ({0})
|
||||
|
||||
@@ -1,20 +1,28 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.openapi.project.impl.shared
|
||||
|
||||
import com.intellij.configurationStore.NOTIFICATION_GROUP_ID
|
||||
import com.intellij.configurationStore.StorageManagerFileWriteRequestor
|
||||
import com.intellij.configurationStore.StreamProvider
|
||||
import com.intellij.configurationStore.getFileRelativeToRootConfig
|
||||
import com.intellij.diagnostic.DiagnosticBundle
|
||||
import com.intellij.notification.Notification
|
||||
import com.intellij.notification.NotificationType
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.components.RoamingType
|
||||
import com.intellij.openapi.components.StoragePathMacros
|
||||
import com.intellij.openapi.diagnostic.logger
|
||||
import com.intellij.openapi.diagnostic.trace
|
||||
import com.intellij.util.io.basicAttributesIfExists
|
||||
import org.jdom.JDOMException
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
import java.nio.file.FileVisitResult
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.SimpleFileVisitor
|
||||
import java.nio.file.attribute.BasicFileAttributes
|
||||
import javax.xml.stream.XMLStreamException
|
||||
import kotlin.io.path.exists
|
||||
import kotlin.io.path.fileSize
|
||||
import kotlin.io.path.name
|
||||
@@ -32,9 +40,20 @@ internal class SharedConfigFolderStreamProvider(private val root: Path) : Stream
|
||||
|
||||
val file = resolveSpec(fileSpec)
|
||||
if (checkFile(file)) {
|
||||
SharedConfigFolderUtil.readNonEmptyFileWithRetries(file) { stream ->
|
||||
LOG.trace { "read ${file.fileSize()} bytes from $file" }
|
||||
stream.use(consumer)
|
||||
try {
|
||||
SharedConfigFolderUtil.readNonEmptyFileWithRetries(file) { stream ->
|
||||
LOG.trace { "read ${file.fileSize()} bytes from $file" }
|
||||
stream.use(consumer)
|
||||
}
|
||||
}
|
||||
catch (e: JDOMException) {
|
||||
processReadException(e, file, consumer)
|
||||
}
|
||||
catch (e: XMLStreamException) {
|
||||
processReadException(e, file, consumer)
|
||||
}
|
||||
catch (e: IOException) {
|
||||
processReadException(e, file, consumer)
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -43,6 +62,19 @@ internal class SharedConfigFolderStreamProvider(private val root: Path) : Stream
|
||||
return true
|
||||
}
|
||||
|
||||
private fun processReadException(e: Exception, file: Path, consumer: (InputStream?) -> Unit) {
|
||||
LOG.warn(e)
|
||||
val app = ApplicationManager.getApplication()
|
||||
if (app != null && !app.isUnitTestMode && !app.isHeadlessEnvironment) {
|
||||
Notification(NOTIFICATION_GROUP_ID,
|
||||
DiagnosticBundle.message("notification.cannot.load.settings.title"),
|
||||
DiagnosticBundle.message("notification.cannot.load.settings.content", file, e.message),
|
||||
NotificationType.WARNING)
|
||||
.notify(null)
|
||||
}
|
||||
consumer(null)
|
||||
}
|
||||
|
||||
override fun processChildren(path: String,
|
||||
roamingType: RoamingType,
|
||||
filter: (name: String) -> Boolean,
|
||||
|
||||
Reference in New Issue
Block a user