Issue 2264 Attempting to oblit into a file containing '/'s will fail

Title Attempting to oblit into a file containing '/'s will fail
Priority bug Status needs-implementation
Milestone Resolved in
Superseder Nosy List owst
Assigned To

Created on 2012-10-31.11:51:50 by owst, last changed 2022-11-19.16:46:56 by bfrk.

msg16269 (view) Author: owst Date: 2012-10-31.11:51:49
I didn't think about what I was doing and did something like this:

    darcs ob --last 1 -a -o "stash-2012/10/31.dpatch"

forgetting that -o creates a *file*.

darcs died with:

    darcs: /tmp/repo/stash-2012/10/31.dpatch-0: takeFile
/tmp/repo/stash-2012/10/31.dpatch-0 in /tmp/repo: does not exist (No
such file or directory)

Clearly, the '/'s are invalid in a filename; we should attempt to catch
invalid file names in a more pleasant way.
msg16276 (view) Author: owst Date: 2012-11-01.00:33:54
This is a bit tricky.

Pull/Send/Obliterate(which is in Unrecord.hs) all create bundles. They
all parse the options attempting to find a "-o FILE", and then make a
bundle - we should create a single function to write out a given bundle
and get the output name from the options.

The actual failure occurs in Repository/Lock where wordReadableTemp
calls takeFile, which fails due to the stash-2012 "directory" not
existing. I suppose takeFile could/should check that its filepath
argument is valid (though I'm not sure how to do this without attempting
to create the file (which may already exist!)).

It might be nice to do a bit of sanity checking when parsing the
arguments, i.e. when reading a -o flag, check whether the path looks
sane in some central point...

More thinking/investigation required.
msg17257 (view) Author: bfrk Date: 2014-04-03.13:46:16
Why not:

if file exists then
  warn about overwriting existing file
  and ask user for confirmation
  if not confirmed then exit
  try to create file
  if it fails then exit
go write the file
msg22435 (view) Author: bfrk Date: 2020-08-15.19:53:45
Note that this works fine if the directory "stash-2012/10" exists:

ben@home[1]:.../scratch/R>mkdir -p stash-2012/10
ben@home[1]:.../scratch/R>darcs ob --last 1 -a -o "stash-
Minimizing context, to generate bundle with full context hit ctrl-
Saved patch bundle /home/ben/scratch/R/stash-2012/10/31.dpatch.
Finished obliterating.

The error message could be clearer, though.
Date User Action Args
2012-10-31 11:51:50owstcreate
2012-11-01 00:33:57owstsetmessages: + msg16276
2014-04-03 13:46:17bfrksetmessages: + msg17257
2020-08-15 19:53:49bfrksetmessages: + msg22435
2022-04-12 13:32:28bfrksetstatus: unknown -> needs-implementation
priority: bug
2022-11-19 16:44:38bfrksetfiles: + patch-preview.txt, bugfix-for-darcs-repair.dpatch
messages: + msg23043
2022-11-19 16:46:43bfrksetmessages: - msg23043
2022-11-19 16:46:52bfrksetfiles: - bugfix-for-darcs-repair.dpatch
2022-11-19 16:46:56bfrksetfiles: - patch-preview.txt