Skip to content

Commit

Permalink
Merge pull request #107 from lkk214/fix/download-shirefile-from-marke…
Browse files Browse the repository at this point in the history
…tplace

Fix/download shirefile from marketplace
  • Loading branch information
phodal authored Sep 27, 2024
2 parents 16aa704 + 1ea4ef2 commit ff142f0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.AsyncFileListener
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.vfs.newvfs.events.VFileCopyEvent
import com.intellij.openapi.vfs.newvfs.events.VFileCreateEvent
import com.intellij.openapi.vfs.newvfs.events.VFileDeleteEvent
import com.intellij.openapi.vfs.newvfs.events.VFileEvent
import com.intellij.openapi.vfs.newvfs.events.VFileMoveEvent
Expand Down Expand Up @@ -81,7 +82,7 @@ internal class AsyncShireFileListener : AsyncFileListener, ShireFileListener {
val afterChangedEvents = mutableListOf<VFileEvent>()
for (event in events) {
if (event is VFileDeleteEvent) beforeChangedEvents.add(event)
if (event is VFileCopyEvent || event is VFileMoveEvent) afterChangedEvents.add(event)
if (event is VFileCopyEvent || event is VFileMoveEvent || event is VFileCreateEvent) afterChangedEvents.add(event)
}

return object : AsyncFileListener.ChangeApplier {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ class ShireMarketplaceTableView(val project: Project) {
ShireDownloader(project, item).downloadAndUnzip()
ShirelangNotifications.info(project, "Success Downloaded ${item.title}")

invokeLater {
project.guessProjectDir()?.refresh(true, true)
}

fireEditingStopped()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
package com.phodal.shire.marketplace.util

import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.invokeLater
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.progress.ProgressManager
import com.intellij.openapi.progress.impl.BackgroundableProcessIndicator
import com.intellij.openapi.project.Project
import com.intellij.openapi.project.guessProjectDir
import com.intellij.openapi.util.Computable
import com.intellij.openapi.util.io.FileUtil
import com.intellij.util.download.DownloadableFileService
Expand Down Expand Up @@ -49,7 +51,13 @@ class ShireDownloader(val project: Project, val item: ShirePackage) {
downloadLock.writeLock().lock()
try {
val pluginDir: File = getPluginDir()
return downloadWithProgress { doDownload(pluginDir, downloader) }
return downloadWithProgress {
doDownload(pluginDir, downloader).apply {
invokeLater {
project.guessProjectDir()?.refresh(true, true)
}
}
}
} finally {
downloadLock.writeLock().unlock()
}
Expand Down

0 comments on commit ff142f0

Please sign in to comment.