sftp doesn't allow renaming to an existing file, so remove it first.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23325 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
François Revol 2008-01-09 19:29:35 +00:00
parent a094d41047
commit 61946f580b
2 changed files with 25 additions and 3 deletions

View File

@ -167,10 +167,32 @@ SftpClient::MoveFile(const string& oldPath, const string& newPath)
{
bool rc = false;
int len;
BString cmd("rename");
cmd << " " << oldPath.c_str() << " " << newPath.c_str() << "\n";
// sftpd can't rename to an existing file...
BString cmd("rm");
cmd << " " << newPath.c_str() << "\n";
SendCommand(cmd.String());
BString reply;
if ((len = ReadReply(&reply)) < 0) {
fprintf(stderr, "read: %s\n", len);
return false;
}
fprintf(stderr, "reply: '%s'\n", reply.String());
if (reply.FindFirst("Removing") != 0)
return false;
if ((len = ReadReply(&reply)) < 0) {
fprintf(stderr, "read: %s\n", len);
return false;
}
fprintf(stderr, "reply: '%s'\n", reply.String());
if (reply.FindFirst("sftp>") < 0)
return false;
cmd = "rename";
cmd << " " << oldPath.c_str() << " " << newPath.c_str() << "\n";
SendCommand(cmd.String());
if ((len = ReadReply(&reply)) < 0) {
fprintf(stderr, "read: %s\n", len);
return false;

View File

@ -707,7 +707,7 @@ VideoConsumer::FtpSave(char* filename)
if (ftp->PutFile((string)filename, (string)"temp")) {
// send the file to the server
ftp->Chmod((string)filename, (string)"644");
ftp->Chmod((string)"temp", (string)"644");
// make it world readable
UpdateFtpStatus("Renaming ...");