RejectedSoftware Forums

Sign up

std.file.rename throws on Linux (uploader example)

Hello again!

For me, the uploader example doesn't work. After trying to upload a plain text file from my home directory, I get this:

500 - Internal Server Error

Internal Server Error

Internal error information:
std.file.FileException@std/file.d(512): ./plain.txt: Invalid cross-device link
----------------
/tmp/.rdmd-1000/rdmd-app.d-23280FC3AB18267B6514692665DC42ED/app(void std.file.rename(const(char[]), const(char[]))+0x89) [0x6102f9]
/tmp/.rdmd-1000/rdmd-app.d-23280FC3AB18267B6514692665DC42ED/app(void vibe.core.file.moveFile(immutable(char)[], immutable(char)[])+0x3b) [0x54866f]
/tmp/.rdmd-1000/rdmd-app.d-23280FC3AB18267B6514692665DC42ED/app(void vibe.core.file.moveFile(vibe.inet.path.Path, vibe.inet.path.Path)+0x3d) [0x548631]
/tmp/.rdmd-1000/rdmd-app.d-23280FC3AB18267B6514692665DC42ED/app(void app.uploadFile(vibe.http.server.HttpServerRequest, vibe.http.server.HttpServerResponse)+0xec) [0x51ec08]
/tmp/.rdmd-1000/rdmd-app.d-23280FC3AB18267B6514692665DC42ED/app(void std.functional.DelegateFaker!(void function(vibe.http.server.HttpServerRequest, vibe.http.server.HttpServerResponse)*).DelegateFaker.doIt(vibe.http.server.HttpServerRequest, vibe.http.server.HttpServerResponse)+0x68) [0x5555c8]
/tmp/.rdmd-1000/rdmd-app.d-23280FC3AB18267B6514692665DC42ED/app(void vibe.http.router.UrlRouter.handleRequest(vibe.http.server.HttpServerRequest, vibe.http.server.HttpServerResponse)+0x182) [0x5551e6]
/tmp/.rdmd-1000/rdmd-app.d-23280FC3AB18267B6514692665DC42ED/app(bool vibe.http.server.handleRequest(vibe.stream.stream.Stream, immutable(char)[], vibe.http.server.HTTPServerListener, ref vibe.http.server.HttpServerSettings)+0x12d7) [0x5cc4a7]
/tmp/.rdmd-1000/rdmd-app.d-23280FC3AB18267B6514692665DC42ED/app(void vibe.http.server.handleHttpConnection(vibe.core.net.TcpConnection, vibe.http.server.HTTPServerListener)+0x1f1) [0x5cb10d]
/tmp/.rdmd-1000/rdmd-app.d-23280FC3AB18267B6514692665DC42ED/app(void vibe.http.server.listenHttpPlain(vibe.http.server.HttpServerSettings, void delegate(vibe.http.server.HttpServerRequest, vibe.http.server.HttpServerResponse)).void doListen(vibe.http.server.HttpServerSettings, vibe.http.server.HTTPServerListener, immutable(char)[]).void __lambda32(vibe.core.net.TcpConnection)+0x36) [0x5c8286]
/tmp/.rdmd-1000/rdmd-app.d-23280FC3AB18267B6514692665DC42ED/app(extern (C) nothrow void vibe.core.drivers.libevent2_tcp.onConnect(int, short, void*).void ClientTask.execute()+0x2a5) [0x55345d]
/tmp/.rdmd-1000/rdmd-app.d-23280FC3AB18267B6514692665DC42ED/app(void vibe.core.core.CoreTask.run()+0x7e) [0x5608b2]
/tmp/.rdmd-1000/rdmd-app.d-23280FC3AB18267B6514692665DC42ED/app(void core.thread.Fiber.run()+0x2a) [0x61f8a6]
/tmp/.rdmd-1000/rdmd-app.d-23280FC3AB18267B6514692665DC42ED/app(fiber_entryPoint+0x61) [0x61f7b9]
[(nil)]

This probably has something to do with rename() not working between different mount points on Linux. I'm not sure how it can be fixed, except manually copying the file and deleting the old one?

Thanks, Matej

Re: std.file.rename throws on Linux (uploader example)

On Mon, 15 Oct 2012 00:20:19 +0200, Matej Nanut wrote:

Hello again!

For me, the uploader example doesn't work. After trying to upload a plain text file from my home directory, I get this:

...

This probably has something to do with rename() not working between different mount points on Linux. I'm not sure how it can be fixed, except manually copying the file and deleting the old one?

Yes, I would say copy+delete is the way to go here. I wouldn't want to change the semantics of rename() because it can be quite useful to know that the operation usually does not take long. But maybe the example could use a fallback path, as this situation probably is not too uncommon on Linux...

PS: just noticed that there is no copyFile() function. I'll add that later.