Skip to content

Commit

Permalink
Choose USER-specific tmpdir
Browse files Browse the repository at this point in the history
  • Loading branch information
cdunn2001 committed May 25, 2019
1 parent f17eaef commit c0a305f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/nimblepkg/nimscriptsupport.nim
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ from compiler/scriptconfig import setupVM
from compiler/astalgo import strTableGet
import compiler/options as compiler_options

import common, version, options, packageinfo, cli
import common, version, options, packageinfo, cli, tools
import os, strutils, strtabs, tables, times, osproc, sets, pegs

when not declared(resetAllModulesHard):
Expand Down Expand Up @@ -382,7 +382,7 @@ proc execScript(scriptName: string, flags: Flags, options: Options): PSym =

# Ensure that "nimblepkg/nimscriptapi" is in the PATH.
block:
let t = getTempDir() / "nimblecache"
let t = getNimbleTempDir() / "nimblecache"
let tmpNimscriptApiPath = t / "nimblepkg" / "nimscriptapi.nim"
createDir(tmpNimscriptApiPath.splitFile.dir)
writeFile(tmpNimscriptApiPath, nimscriptApi)
Expand Down
2 changes: 1 addition & 1 deletion src/nimblepkg/publish.nim
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ proc editJson(p: PackageInfo; url, tags, downloadMethod: string) =
proc publish*(p: PackageInfo, o: Options) =
## Publishes the package p.
let auth = getGithubAuth(o)
var pkgsDir = getTempDir() / "nimble-packages-fork"
var pkgsDir = getNimbleTempDir() / "nimble-packages-fork"
if not forkExists(auth):
createFork(auth)
display("Info:", "Waiting 10s to let Github create a fork",
Expand Down
12 changes: 9 additions & 3 deletions src/nimblepkg/tools.nim
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,16 @@ proc getNimbleTempDir*(): string =
## different for different runs of it. You have to make sure to create it
## first. In release builds the directory will be removed when nimble finishes
## its work.
result = getTempDir() / "nimble_"
var tmpdir: string
if existsEnv("TMPDIR") and existsEnv("USER"):
tmpdir = joinPath(getEnv("TMPDIR"), getEnv("USER"))
else:
tmpdir = getTempDir()
var tail = "nimble_"
when defined(windows):
proc GetCurrentProcessId(): int32 {.stdcall, dynlib: "kernel32",
importc: "GetCurrentProcessId".}
result.add($GetCurrentProcessId())
tail.add($GetCurrentProcessId())
else:
result.add($getpid())
tail.add($getpid())
result = joinPath(tmpdir, tail)

0 comments on commit c0a305f

Please sign in to comment.