Opened 12 years ago

Last modified 6 years ago

#767 new enhancement

g.copy only issues warning when destination exists

Reported by: ferrouswheel Owned by: grass-dev@…
Priority: major Milestone: 6.4.6
Component: Default Version: svn-develbranch6
Keywords: g.copy, g.rename Cc:
CPU: Unspecified Platform: Unspecified

Description

g.copy rast=src,dst

When dst already exists, g.copy only issues a "WARNING" message and returns 0 without copying src to dst. This behaviour is erroneous, is should give an "ERROR" message and return non-zero (unless an overwrite flag is enabled).

Change History (8)

comment:1 Changed 10 years ago by neteler

comment:2 Changed 10 years ago by neteler

The same applies to g.rename.

comment:3 Changed 10 years ago by hamish

Keywords: g.copy g.rename added
Milestone: 6.4.06.4.2
Priority: normalmajor

comment:4 in reply to:  1 ; Changed 10 years ago by hamish

Replying to neteler:

What is the reason that there is only G_warning()?

I don't know, but it seems to have been like that since forever.

http://trac.osgeo.org/grass/browser/grass/branches/releasebranch_5_5/src/general/manage/cmd/copy.c?rev=3

G_fatal_error() seems like the right thing to do AFAICT.

Hamish

comment:5 in reply to:  4 Changed 10 years ago by glynn

Replying to hamish:

G_fatal_error() seems like the right thing to do AFAICT.

One issue is that, with multiple map names, it will abort at the first case where the destination exists. Maps prior to that will be copied, maps after that won't be.

The existing behaviour is more consistent: maps which can be copied are copied; errors only affect the specific copy operation to which they apply.

The existing behaviour differs from modules which use ->gisprompt="new,..." (which g.copy can't do because of its interface; see #178). With those, the parser checks either that --overwrite was used or that none of the "new" maps exist. If the check fails, it fails in G_parser(), before the module starts to do any work.

If we want the "usual" behaviour from g.copy and g.rename, they will need to loop over the inputs twice: the first time to check for errors, the second time to actually perform the copy/rename operations.

comment:6 Changed 9 years ago by neteler

Milestone: 6.4.26.4.4
Type: defectenhancement

comment:7 Changed 9 years ago by hamish

see also #1658

comment:8 Changed 6 years ago by neteler

Milestone: 6.4.46.4.6
Note: See TracTickets for help on using tickets.