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:
parent
a094d41047
commit
61946f580b
|
@ -167,10 +167,32 @@ SftpClient::MoveFile(const string& oldPath, const string& newPath)
|
||||||
{
|
{
|
||||||
bool rc = false;
|
bool rc = false;
|
||||||
int len;
|
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());
|
SendCommand(cmd.String());
|
||||||
BString reply;
|
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) {
|
if ((len = ReadReply(&reply)) < 0) {
|
||||||
fprintf(stderr, "read: %s\n", len);
|
fprintf(stderr, "read: %s\n", len);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -707,7 +707,7 @@ VideoConsumer::FtpSave(char* filename)
|
||||||
if (ftp->PutFile((string)filename, (string)"temp")) {
|
if (ftp->PutFile((string)filename, (string)"temp")) {
|
||||||
// send the file to the server
|
// send the file to the server
|
||||||
|
|
||||||
ftp->Chmod((string)filename, (string)"644");
|
ftp->Chmod((string)"temp", (string)"644");
|
||||||
// make it world readable
|
// make it world readable
|
||||||
|
|
||||||
UpdateFtpStatus("Renaming ...");
|
UpdateFtpStatus("Renaming ...");
|
||||||
|
|
Loading…
Reference in New Issue