Skip to content

Commit ebf95bc

Browse files
committed
remove clip file
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com> Change-Id: I5b8453fddb102ce5762fa82397158dd3eed3da36
1 parent e70e897 commit ebf95bc

File tree

1 file changed

+12
-23
lines changed

1 file changed

+12
-23
lines changed

wsd/ClientSession.cpp

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2458,11 +2458,17 @@ bool ClientSession::handleKitToClientMessage(const std::shared_ptr<Message>& pay
24582458
fileStream.close();
24592459

24602460
// final cleanup ...
2461+
bool removeClipFile = true;
24612462
if (!empty && (!_wopiFileInfo || !_wopiFileInfo->getDisableCopy()))
24622463
{
24632464
fprintf(stderr, "save clipboard\n");
2464-
// remove on else
2465-
clipFile = COOLWSD::SavedClipboards->insertClipboard(_clipboardKeys, clipFile);
2465+
// returns same filename as its arg on rename failure
2466+
std::string cacheFile = COOLWSD::SavedClipboards->insertClipboard(_clipboardKeys, clipFile);
2467+
if (cacheFile != clipFile)
2468+
{
2469+
clipFile = cacheFile;
2470+
removeClipFile = false;
2471+
}
24662472
}
24672473
else
24682474
fprintf(stderr, "don't save clipboard\n");
@@ -2476,27 +2482,6 @@ bool ClientSession::handleKitToClientMessage(const std::shared_ptr<Message>& pay
24762482
fprintf(stderr, "PAYLOAD LEN is %ld\n", res.size());
24772483

24782484
// The custom header for the clipboard of a living document.
2479-
#if 0
2480-
http::Response httpResponse(http::StatusCode::OK);
2481-
httpResponse.set("Last-Modified", Util::getHttpTimeNow());
2482-
httpResponse.add("Content-Type", "application/octet-stream");
2483-
httpResponse.add("X-Content-Type-Options", "nosniff");
2484-
httpResponse.add("X-COOL-Clipboard", "true");
2485-
httpResponse.add("Cache-Control", "no-cache");
2486-
httpResponse.set("Connection", "close");
2487-
2488-
2489-
httpResponse.set("Content-Length", std::to_string(res.size()));
2490-
socket->send(httpResponse);
2491-
2492-
if (!empty)
2493-
{
2494-
socket->setSocketBufferSize(
2495-
std::min(res.size() + 256, std::size_t(Socket::MaximumSendBufferSize)));
2496-
socket->send(res.data(), res.size());
2497-
}
2498-
socket->shutdown();
2499-
#endif
25002485
auto session = std::make_shared<http::ServerSession>();
25012486

25022487
http::ServerSession::ResponseHeaders headers;
@@ -2513,6 +2498,10 @@ bool ClientSession::handleKitToClientMessage(const std::shared_ptr<Message>& pay
25132498

25142499
LOG_INF("Queued " << (empty?"empty":"clipboard") << " response for send.");
25152500
}
2501+
2502+
fprintf(stderr, "removeClipFile is %d\n", removeClipFile);
2503+
if (removeClipFile)
2504+
FileUtil::removeFile(clipFile);
25162505
#endif
25172506
_clipSockets.clear();
25182507
return true;

0 commit comments

Comments
 (0)