[GRASS-dev] [GRASS GIS] #1902: g.tempfile -d: make a directory not a filename

#1902: g.tempfile -d: make a directory not a filename
-----------------------------------+----------------------------------------
Reporter: hamish | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Default | Version: svn-trunk
Keywords: g.tempfile, scripting | Platform: All
      Cpu: All |
-----------------------------------+----------------------------------------
Hi,

in grass7 there is a new `g.tempfile -d` flag to do a "dry run". It is
used in core.py by grass.tempdir() to later make a directory by the
returned string name. This has three things against it: 1) it causes a
race condition. 2) it diverges from the usage of `/bin/mktemp -d`, which
is used to make a directory. 3) it's a lot more convoluted than just
making the tempfile a directory in the first place, which is the only(?)
known use of -d for dryrun.

I propose that the -d flag in g.tempfile be changed to match mktemp's
usage, i.e. make a directory instead.

It is not present in grass6, so there is not a backwards compatibility
problem to change it now. I'd suggest that the -d flag to make a new
directory would be useful to backport to grass6 once it is ready.

thanks,
Hamish

ps- argh trac is logging out every 5 minutes again

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1902&gt;
GRASS GIS <http://grass.osgeo.org>

#1902: g.tempfile -d: make a directory not a filename
-----------------------------------+----------------------------------------
Reporter: hamish | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Default | Version: svn-trunk
Keywords: g.tempfile, scripting | Platform: All
      Cpu: All |
-----------------------------------+----------------------------------------

Comment(by martinl):

No objections, feel free to implement it.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1902#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#1902: g.tempfile -d: make a directory not a filename
-------------------------------------------+--------------------------------
Reporter: hamish | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Default | Version: svn-trunk
Keywords: g.tempfile, scripting, mktemp | Platform: All
      Cpu: All |
-------------------------------------------+--------------------------------
Changes (by neteler):

  * keywords: g.tempfile, scripting => g.tempfile, scripting, mktemp

Comment:

(Un)related:

To avoid race conditions on high end systems, the use of PID is not save.
For a new G_mktemp() implementation, see also ticket #2153

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1902#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>