Merge pull request #656 from cdunn2001/master

Choose USER-specific tmpdir
This commit is contained in:
Dominik Picheta 2019-05-27 11:24:31 +01:00 committed by GitHub
commit a4eaa5d3d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 3 deletions

View file

@ -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):
@ -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 = getNimbleUserTempDir() / "nimblecache"
let tmpNimscriptApiPath = t / "nimblepkg" / "nimscriptapi.nim"
createDir(tmpNimscriptApiPath.splitFile.dir)
writeFile(tmpNimscriptApiPath, nimscriptApi)

View file

@ -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 = getNimbleUserTempDir() / "nimble-packages-fork"
if not forkExists(auth):
createFork(auth)
display("Info:", "Waiting 10s to let Github create a fork",

View file

@ -162,3 +162,17 @@ proc getNimbleTempDir*(): string =
result.add($GetCurrentProcessId())
else:
result.add($getpid())
proc getNimbleUserTempDir*(): string =
## Returns a path to a temporary directory.
##
## The returned path will be the same for the duration of the process but
## 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.
var tmpdir: string
if existsEnv("TMPDIR") and existsEnv("USER"):
tmpdir = joinPath(getEnv("TMPDIR"), getEnv("USER"))
else:
tmpdir = getTempDir()
return tmpdir