Skip to content
Browse files

Add QUERY_FILETRANSFER REQUEST_SIZE command

This allows to query the current size of the file. Previously you could only get the size of the file from when it was first opened or had to issue a QUERY_FILE_EXISTS command that is significantly slower (as it requires a new connection to the backend)
  • Loading branch information...
1 parent cad3f0a commit 5f47d6922e8e2d740ffd9353bf8d354a189ef80d @jyavenard jyavenard committed Mar 9, 2014
View
6 mythtv/libs/libmythprotoserver/requesthandler/fileserverhandler.cpp
@@ -1038,6 +1038,12 @@ bool FileServerHandler::HandleQueryFileTransfer(SocketHandler *socket,
res << "OK";
}
}
+ else if (slist[1] == "REQUEST_SIZE")
+ {
+ // return size and if the file is not opened for writing
+ res << QString::number(ft->GetFileSize());
+ res << QString::number(!gCoreContext->IsRegisteredFileForWrite(ft->GetFileName()));
+ }
else
{
LOG(VB_GENERAL, LOG_ERR, "Invalid QUERY_FILETRANSFER call");
View
8 mythtv/libs/libmythprotoserver/sockethandler/filetransfer.cpp
@@ -258,6 +258,14 @@ uint64_t FileTransfer::GetFileSize(void)
return rbuffer->GetRealFileSize();
}
+QString FileTransfer::GetFileName(void)
+{
+ if (!rbuffer)
+ return QString();
+
+ return rbuffer->GetFilename();
+}
+
void FileTransfer::SetTimeout(bool fast)
{
if (pginfo)
View
1 mythtv/libs/libmythprotoserver/sockethandler/filetransfer.h
@@ -40,6 +40,7 @@ class FileTransfer : public SocketHandler
long long Seek(long long curpos, long long pos, int whence);
uint64_t GetFileSize(void);
+ QString GetFileName(void);
void SetTimeout(bool fast);
View
8 mythtv/programs/mythbackend/filetransfer.cpp
@@ -260,6 +260,14 @@ uint64_t FileTransfer::GetFileSize(void)
return rbuffer->GetRealFileSize();
}
+QString FileTransfer::GetFileName(void)
+{
+ if (!rbuffer)
+ return QString();
+
+ return rbuffer->GetFilename();
+}
+
void FileTransfer::SetTimeout(bool fast)
{
if (pginfo)
View
1 mythtv/programs/mythbackend/filetransfer.h
@@ -44,6 +44,7 @@ class FileTransfer : public ReferenceCounter
long long Seek(long long curpos, long long pos, int whence);
uint64_t GetFileSize(void);
+ QString GetFileName(void);
void SetTimeout(bool fast);
View
8 mythtv/programs/mythbackend/mainserver.cpp
@@ -5803,11 +5803,17 @@ void MainServer::HandleFileTransferQuery(QStringList &slist,
ft->SetTimeout(fast);
retlist << "OK";
}
+ else if (command == "REQUEST_SIZE")
+ {
+ // return size and if the file is not opened for writing
+ retlist << QString::number(ft->GetFileSize());
+ retlist << QString::number(!gCoreContext->IsRegisteredFileForWrite(ft->GetFileName()));
+ }
else
{
LOG(VB_GENERAL, LOG_ERR, LOC +
QString("Unknown command: %1").arg(command));
- retlist << "OK";
+ retlist << "ERROR" << "invalid_call";
}
ft->DecrRef();

0 comments on commit 5f47d69

Please sign in to comment.
Something went wrong with that request. Please try again.