On Sun, Jan 10, 2016 at 12:44:12AM +0100, Enrico Forestieri wrote: > On Thu, Dec 31, 2015 at 09:13:02PM +0100, Georg Baum wrote: > > > Sorry for opening a new thread, but gmane did already expire the old thread > > in the nntp interface, and I do not keep lyx-devel mails. > > > > The attached patch implements the third option I described in the starting > > message of the original thread: > > > > > - Do not change the paths in general if the files can be found using the > > > relative paths. Has the additional benefit that this is also the wanted > > > behaviour if I copy a whole directory of LyX files (including referenced > > > graphics) to a new location. Disadvantage would be that the machinery does > > > now depend on the presence of external files, and it is not guaranteed > > > that the file that is found is the correct one. > > I am fine with this and you have a +1 from me. However, note that the origin > handling is currently broken. Indeed, allowing to save the document directory > in the preferences, after creating a new file and saving it, the path in the > origin tag is missing the trailing slash and thus it will not work. > This was working fine until not so long ago, hence it must have been broken > recently, most probably by the patches for dealing with symlinks.
The attached patch fixes the above issue. BTW, your patch works very well :) -- Enrico
diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index fe47c05..8024d4a 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -1015,11 +1015,11 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const // The top of the file is written by the buffer. // Prints out the buffer info into the .lyx file given by file - // the document directory - // use realPath() instead of absFileName() for comparing - // so we can catch also eventually used symbolic parts of the path. - string filepath = buf->fileName().onlyPath().realPath(); - string const sysdir = package().system_support().realPath(); + // the document directory (must end with a path separator) + // realPath() is used to resolve symlinks, while addPath(..., "") + // ensures a trailing path separator. + string filepath = addPath(buf->fileName().onlyPath().realPath(), ""); + string const sysdir = addPath(package().system_support().realPath(), ""); string const relpath = to_utf8(makeRelPath(from_utf8(filepath), from_utf8(sysdir))); if (!prefixIs(relpath, "../") && !FileName::isAbsolute(relpath))