Skip to content

Commit

Permalink
Merge branch 'bugfix/IJMP-1534' into 'release/v1.2.1-221'
Browse files Browse the repository at this point in the history
IJMP-1534: fix renaming of open files

See merge request ijmp/for-mainframe!495
  • Loading branch information
Dzianis Lisiankou committed Mar 26, 2024
2 parents 919aebb + 0945331 commit a50c3aa
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ class RemoteDatasetAttributesService(
val volserDir = fsModel.findOrCreate(
this, subDirectory, newAttributes.volser ?: MIGRATED, createAttributes(directory = true)
)
fsModel.moveFile(this, file, volserDir)
file.move(this, volserDir)
}
if (oldAttributes.name != newAttributes.name) {
fsModel.renameFile(this, file, newAttributes.name)
file.rename(this, newAttributes.name)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class RemoteJobAttributesService(
newAttributes: RemoteJobAttributes
) {
if (oldAttributes.name != newAttributes.name) {
fsModel.renameFile(this, file, newAttributes.name)
file.rename(this, newAttributes.name)
fsModel.setWritable(file, false)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ class RemoteUssAttributesService(
fsModel.setWritable(file, newAttributes.isWritable)
file.isReadable = newAttributes.isReadable
if (oldAttributes.name != newAttributes.name) {
fsModel.renameFile(this, file, newAttributes.name)
file.rename(this, newAttributes.name)
}
if (oldAttributes.parentDirPath != newAttributes.parentDirPath) {
var current = subDirectory
var current = fsRoot
createPathChain(newAttributes).dropLast(1).map { nameWithFileAttr ->
findOrCreate(current, nameWithFileAttr).also { current = it }
}
fsModel.moveFile(this, file, current)
file.move(this, current)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import eu.ibagroup.formainframe.dataops.exceptions.CallException
import eu.ibagroup.formainframe.explorer.actions.DuplicateMemberAction
import eu.ibagroup.formainframe.utils.cancelByIndicator
import eu.ibagroup.formainframe.utils.log
import eu.ibagroup.formainframe.vfs.sendMFVfsChangesTopic
import eu.ibagroup.formainframe.utils.runWriteActionInEdtAndWait
import org.zowe.kotlinsdk.*

/**
Expand Down Expand Up @@ -81,7 +81,9 @@ class RenameOperationRunner(private val dataOpsManager: DataOpsManager) : Operat
toDatasetName = operation.newName
).cancelByIndicator(progressIndicator).execute()
if (response.isSuccessful) {
sendMFVfsChangesTopic()
runWriteActionInEdtAndWait {
operation.file.rename(this, operation.newName)
}
} else {
throw CallException(response, "Unable to rename the selected dataset")
}
Expand Down Expand Up @@ -113,9 +115,7 @@ class RenameOperationRunner(private val dataOpsManager: DataOpsManager) : Operat
toDatasetName = parentAttributes.datasetInfo.name,
memberName = operation.newName
).cancelByIndicator(progressIndicator).execute()
if (response.isSuccessful) {
sendMFVfsChangesTopic()
} else {
if (!response.isSuccessful) {
throw CallException(response, "Unable to duplicate the selected member")
}
} else {
Expand All @@ -131,7 +131,9 @@ class RenameOperationRunner(private val dataOpsManager: DataOpsManager) : Operat
memberName = operation.newName
).cancelByIndicator(progressIndicator).execute()
if (response.isSuccessful) {
sendMFVfsChangesTopic()
runWriteActionInEdtAndWait {
operation.file.rename(this, operation.newName)
}
} else {
throw CallException(response, "Unable to rename the selected member")
}
Expand All @@ -158,7 +160,9 @@ class RenameOperationRunner(private val dataOpsManager: DataOpsManager) : Operat
filePath = FilePath("$parentDirPath/${operation.newName}")
).cancelByIndicator(progressIndicator).execute()
if (response.isSuccessful) {
sendMFVfsChangesTopic()
runWriteActionInEdtAndWait {
operation.file.rename(this, operation.newName)
}
} else {
throw CallException(response, "Unable to rename the selected file or directory")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,13 @@ class MFVirtualFileSystemModel {
@Throws(IOException::class)
fun renameFile(requestor: Any?, vFile: MFVirtualFile, newName: String) {
val event = listOf(VFilePropertyChangeEvent(requestor, vFile, VirtualFile.PROP_NAME, vFile.name, newName, false))
sendMFVfsChangesTopic().before(event)
sendVfsChangesTopic().before(event)
vFile.validReadLock {
if (vFile.filenameInternal != newName) {
vFile.filenameInternal = newName
}
}
sendMFVfsChangesTopic().after(event)
sendVfsChangesTopic().after(event)
}

@Throws(IOException::class)
Expand Down

0 comments on commit a50c3aa

Please sign in to comment.