diff --git a/sources/lib/commands.go b/sources/lib/commands.go index af95758..e7ad121 100644 --- a/sources/lib/commands.go +++ b/sources/lib/commands.go @@ -281,8 +281,11 @@ func doHandleExecuteScriptletSsh (_library LibraryStore, _scriptlet *Scriptlet, _sshCache = "/tmp" } + if _error := makeCacheFolder (_context.cacheRoot, "ssh-sockets"); _error != nil { + return false, _error + } if _sshLibraryLocalSocket == "" { - _sshLibraryLocalSocket = path.Join (_context.cacheRoot, fmt.Sprintf ("%s-%08x.sock", _sshToken, os.Getpid ())) + _sshLibraryLocalSocket = path.Join (_context.cacheRoot, "ssh-sockets", fmt.Sprintf ("%s-%08x.sock", _sshToken, os.Getpid ())) } if _sshLibraryRemoteSocket == "" { _sshLibraryRemoteSocket = path.Join (_sshCache, fmt.Sprintf ("z-run--%s.sock", _sshToken)) @@ -308,7 +311,7 @@ func doHandleExecuteScriptletSsh (_library LibraryStore, _scriptlet *Scriptlet, ExecutablePaths : _invokeExecutablePaths, Terminal : _sshTerminal, Workspace : _sshWorkspace, - Cache : _sshCache, + CacheRoot : _sshCache, } var _invokeContextEncoded string diff --git a/sources/lib/execution.go b/sources/lib/execution.go index 3d9e15d..6751b99 100644 --- a/sources/lib/execution.go +++ b/sources/lib/execution.go @@ -388,9 +388,19 @@ func prepareExecution_0 ( case "", "" : + if _error := makeCacheFolder (_contextCacheRoot, "go-root"); _error != nil { + return nil, nil, _error + } + if _error := makeCacheFolder (_contextCacheRoot, "go-sources"); _error != nil { + return nil, nil, _error + } + if _error := makeCacheFolder (_contextCacheRoot, "go-executables"); _error != nil { + return nil, nil, _error + } + _goFingerprint := _scriptletFingerprint - _goSource := path.Join (_contextCacheRoot, _goFingerprint + ".go") - _goExecutable := path.Join (_contextCacheRoot, _goFingerprint + ".exec") + _goSource := path.Join (_contextCacheRoot, "go-sources", _goFingerprint + ".go") + _goExecutable := path.Join (_contextCacheRoot, "go-executables", _goFingerprint + ".exec") if _, _error := os.Stat (_goExecutable); _error == nil { // PASS @@ -419,7 +429,7 @@ func prepareExecution_0 ( _interpreterScriptBuffer.WriteString (_scriptletBody) } - _goSourceTmp := path.Join (_contextCacheRoot, generateRandomToken () + ".tmp") + _goSourceTmp := path.Join (_contextCacheRoot, "go-sources", generateRandomToken () + ".tmp") if _error := os.WriteFile (_goSourceTmp, _interpreterScriptBuffer.Bytes (), 0600); _error != nil { return nil, nil, errorw (0x55976c12, _error) } @@ -427,9 +437,9 @@ func prepareExecution_0 ( return nil, nil, errorw (0x5367f11a, _error) } - _goExecutableTmp := path.Join (_contextCacheRoot, generateRandomToken () + ".tmp") + _goExecutableTmp := path.Join (_contextCacheRoot, "go-executables", generateRandomToken () + ".tmp") - _goRoot := path.Join (_contextCacheRoot, "go") + _goRoot := path.Join (_contextCacheRoot, "go-root") _goCache := path.Join (_goRoot, "cache") _goTmp := path.Join (_goRoot, "tmp") for _, _mkdirPath := range []string { _goRoot, _goCache, _goTmp } { diff --git a/sources/lib/main.go b/sources/lib/main.go index b918318..c74f367 100644 --- a/sources/lib/main.go +++ b/sources/lib/main.go @@ -53,7 +53,7 @@ type InvokeContext struct { ExecutablePaths []string `json:"executable-paths,omitempty"` Terminal string `json:"terminal,omitempty"` Workspace string `json:"workspace,omitempty"` - Cache string `json:"cache,omitempty"` + CacheRoot string `json:"cache-root,omitempty"` } @@ -409,7 +409,7 @@ func Main (_executable string, _argument0 string, _arguments []string, _environm _terminal = _context.Terminal _libraryCacheUrl = _context.Library _workspace = _context.Workspace - _cacheRoot = _context.Cache + _cacheRoot = _context.CacheRoot _top = false } diff --git a/sources/lib/parser.go b/sources/lib/parser.go index 2ad6a3d..8f24b4c 100644 --- a/sources/lib/parser.go +++ b/sources/lib/parser.go @@ -49,7 +49,10 @@ func parseLibrary (_sources []*Source, _environmentFingerprint string, _context return nil, _error } - _libraryUrl := fmt.Sprintf ("unix:%s", path.Join (_context.cacheRoot, fmt.Sprintf ("%s-%08x.sock", generateRandomToken (), os.Getpid ()))) + if _error := makeCacheFolder (_context.cacheRoot, "parse-sockets"); _error != nil { + return nil, _error + } + _libraryUrl := fmt.Sprintf ("unix:%s", path.Join (_context.cacheRoot, "parse-sockets", fmt.Sprintf ("%s-%08x.sock", generateRandomToken (), os.Getpid ()))) var _rpc *LibraryRpcServer if _rpc_0, _error := NewLibraryRpcServer (_library, _libraryUrl); _error == nil { diff --git a/sources/lib/resolution.go b/sources/lib/resolution.go index 4a07a92..ac6b23c 100644 --- a/sources/lib/resolution.go +++ b/sources/lib/resolution.go @@ -240,7 +240,10 @@ func resolveLibrary (_candidate string, _context *Context, _lookupPaths []string var _cacheLibrary string if _context.cacheEnabled && (_context.cacheRoot != "") { - _cacheLibrary = path.Join (_context.cacheRoot, _environmentFingerprint + ".cdb") + if _error := makeCacheFolder (_context.cacheRoot, "libraries-cdb"); _error != nil { + return nil, _error + } + _cacheLibrary = path.Join (_context.cacheRoot, "libraries-cdb", _environmentFingerprint + ".cdb") if _, _error := os.Stat (_cacheLibrary); _error == nil { if _library, _error := resolveLibraryCached (_cacheLibrary); _error == nil { if _fresh, _error := checkLibraryCached (_library); _error == nil { diff --git a/sources/lib/tools.go b/sources/lib/tools.go index 8b81b7e..168aa7e 100644 --- a/sources/lib/tools.go +++ b/sources/lib/tools.go @@ -152,3 +152,14 @@ func replaceVariables (_input string) (string, *Error) { return _input, nil } + + + +func makeCacheFolder (_cacheRoot string, _cacheFolder string) (*Error) { + _cache := path.Join (_cacheRoot, _cacheFolder) + if _error := os.MkdirAll (_cache, 0750); _error != nil { + return errorw (0x6f530744, _error) + } + return nil +} + diff --git a/sources/lib/tools_linux.go b/sources/lib/tools_linux.go index 9e28085..7edaafa 100644 --- a/sources/lib/tools_linux.go +++ b/sources/lib/tools_linux.go @@ -41,7 +41,10 @@ func createPipe (_size int, _cacheRoot string) (int, *os.File, *Error) { // FIXME: We should make sure that the cache path is never empty! panic (0xd6f17610) } - _temporaryPath := path.Join (_cacheRoot, generateRandomToken () + ".buffer") + if _error := makeCacheFolder (_cacheRoot, "buffers"); _error != nil { + return -1, nil, _error + } + _temporaryPath := path.Join (_cacheRoot, "buffers", generateRandomToken () + ".buffer") if _descriptor, _error := syscall.Open (_temporaryPath, syscall.O_CREAT | syscall.O_EXCL | syscall.O_WRONLY, 0600); _error == nil { _interpreterScriptOutput = os.NewFile (uintptr (_descriptor), "") } else { diff --git a/sources/lib/tools_others.go b/sources/lib/tools_others.go index 2933560..0852710 100644 --- a/sources/lib/tools_others.go +++ b/sources/lib/tools_others.go @@ -46,7 +46,10 @@ func createPipe (_size int, _cacheRoot string) (int, *os.File, *Error) { // FIXME: We should make sure that the cache path is never empty! panic (0xd6f17610) } - _temporaryPath := path.Join (_cacheRoot, generateRandomToken () + ".buffer") + if _error := makeCacheFolder (_cacheRoot, "buffers"); _error != nil { + return -1, nil, _error + } + _temporaryPath := path.Join (_cacheRoot, "buffers", generateRandomToken () + ".buffer") if _descriptor, _error := syscall.Open (_temporaryPath, syscall.O_CREAT | syscall.O_EXCL | syscall.O_WRONLY, 0600); _error == nil { _interpreterScriptOutput = os.NewFile (uintptr (_descriptor), "") } else {