mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-57814: (WIP): `WslSync` should have ability to mark files executable.
``server`` is binary, hence we add ``exec.txt`` with list of files to mark with ``chmod +x`` Merge-request: IJ-MR-103367 Merged-by: Ilya Kazakevich <ilya.kazakevich@jetbrains.com> GitOrigin-RevId: 0d7dd157413c0783b5fdcc35f33f3e50b62321a3
This commit is contained in:
committed by
intellij-monorepo-bot
parent
db4cb88dc6
commit
1f36544d00
@@ -177,6 +177,8 @@ class WslSyncTest(private val linToWin: Boolean) {
|
||||
val modifyEachFile = 3
|
||||
|
||||
val windowsDir = winDirRule.newDirectoryPath()
|
||||
val executable = "execfile"
|
||||
val execTxt = "exec.txt"
|
||||
val fileNames = (0..numberOfFiles).map { "$it-по-русски.txt" }
|
||||
|
||||
val srcDir = if (linToWin) linuxDirAsPath else windowsDir
|
||||
@@ -185,8 +187,13 @@ class WslSyncTest(private val linToWin: Boolean) {
|
||||
for (fileName in fileNames) {
|
||||
srcDir.resolve(fileName).writeText("hello $fileName")
|
||||
}
|
||||
srcDir.resolve(executable).writeText("#!/bin/sh")
|
||||
srcDir.resolve(execTxt).writeText(" $executable ") // Must be marked executable on Linux
|
||||
|
||||
WslSync.syncWslFolders(linuxDirRule.dir, windowsDir, wslRule.wsl, linToWin)
|
||||
if (!linToWin) {
|
||||
wslRule.wsl.runCommand("${linuxDirRule.dir}/$executable").getOrThrow()
|
||||
}
|
||||
|
||||
val modificationTimes = mutableMapOf<Path, FileTime>()
|
||||
for (fileName in fileNames) {
|
||||
@@ -195,7 +202,7 @@ class WslSyncTest(private val linToWin: Boolean) {
|
||||
Assert.assertEquals("Copied with wrong content", "hello $fileName", file.readText())
|
||||
modificationTimes[file] = file.lastModified()
|
||||
}
|
||||
Assert.assertEquals(fileNames.size, dstDir.toFile().list()!!.size)
|
||||
Assert.assertEquals(fileNames.size + 2, dstDir.toFile().list()!!.size) // + exec files
|
||||
|
||||
Thread.sleep(1000) // To check modification time
|
||||
|
||||
|
||||
@@ -172,5 +172,9 @@ class LinuxFileStorage(dir: LinuxFilePath, distro: AbstractWslDistribution, filt
|
||||
script.first.delete()
|
||||
}
|
||||
}
|
||||
|
||||
fun markExec(fileToMarkExec: String) {
|
||||
distro.runCommand("chmod", "+x", "$dir/$fileToMarkExec").getOrThrow()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,11 +9,16 @@ import java.nio.file.Path
|
||||
import java.util.concurrent.CompletableFuture.runAsync
|
||||
import java.util.concurrent.CompletableFuture.supplyAsync
|
||||
import java.util.concurrent.Future
|
||||
import kotlin.io.path.exists
|
||||
import kotlin.io.path.readText
|
||||
|
||||
|
||||
/**
|
||||
* When copying files in parallel we must split them to the several chunks (each chunk is separate .tar file).
|
||||
* No reason to have less than [MIN_CHUNK_SIZE] files in one chunk: two files shouldn't be split to two chunks
|
||||
*
|
||||
* If source is windows and top level ``exec.txt`` file exists, it should contain list of top level files to mark +x on Linux side
|
||||
* (in case your helper needs to be executable)
|
||||
*/
|
||||
private const val MIN_CHUNK_SIZE = 1000
|
||||
|
||||
@@ -45,6 +50,13 @@ class WslSync<SourceFile, DestFile> private constructor(private val source: File
|
||||
}
|
||||
else {
|
||||
WslSync(win, lin)
|
||||
val execFile = windowsDir.resolve("exec.txt")
|
||||
if (execFile.exists()) {
|
||||
// TODO: Support non top level files
|
||||
for(fileToMarkExec in execFile.readText().split(Regex("\\s+")).map { it.trim() }) {
|
||||
lin.markExec(fileToMarkExec)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user