@@ -2458,11 +2458,17 @@ bool ClientSession::handleKitToClientMessage(const std::shared_ptr<Message>& pay
2458
2458
fileStream.close ();
2459
2459
2460
2460
// final cleanup ...
2461
+ bool removeClipFile = true ;
2461
2462
if (!empty && (!_wopiFileInfo || !_wopiFileInfo->getDisableCopy ()))
2462
2463
{
2463
2464
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
+ }
2466
2472
}
2467
2473
else
2468
2474
fprintf (stderr, " don't save clipboard\n " );
@@ -2476,27 +2482,6 @@ bool ClientSession::handleKitToClientMessage(const std::shared_ptr<Message>& pay
2476
2482
fprintf (stderr, " PAYLOAD LEN is %ld\n " , res.size ());
2477
2483
2478
2484
// 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
2500
2485
auto session = std::make_shared<http::ServerSession>();
2501
2486
2502
2487
http::ServerSession::ResponseHeaders headers;
@@ -2513,6 +2498,10 @@ bool ClientSession::handleKitToClientMessage(const std::shared_ptr<Message>& pay
2513
2498
2514
2499
LOG_INF (" Queued " << (empty?" empty" :" clipboard" ) << " response for send." );
2515
2500
}
2501
+
2502
+ fprintf (stderr, " removeClipFile is %d\n " , removeClipFile);
2503
+ if (removeClipFile)
2504
+ FileUtil::removeFile (clipFile);
2516
2505
#endif
2517
2506
_clipSockets.clear ();
2518
2507
return true ;
0 commit comments