darcs

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

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

Created on 2012-10-31.11:51:50 by owst, last changed 2014-04-03.13:46:17 by bf.

Messages
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: bf 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
else
  try to create file
  if it fails then exit
go write the file
History
Date User Action Args
2012-10-31 11:51:50owstcreate
2012-11-01 00:33:57owstsetmessages: + msg16276
2014-04-03 13:46:17bfsetmessages: + msg17257