| Summary: | fetches dir listing after every upload attempt | ||
|---|---|---|---|
| Product: | [Unmaintained] kftpgrabber | Reporter: | IgnorantGuru <jgj7.kde> |
| Component: | general | Assignee: | Jernej Kos <kostko> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | ||
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | Ubuntu | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
|
Description
IgnorantGuru
2007-04-02 18:27:02 UTC
SVN commit 649480 by kostko:
Fixed cache handling for file uploads.
BUG: 143744
M +35 -7 ftpsocket.cpp
--- trunk/extragear/network/kftpgrabber/src/engine/ftpsocket.cpp #649479:649480
@@ -1668,12 +1668,22 @@
KURL sourceFile;
KURL destinationFile;
+ bool fetchedSize;
+ filesize_t destinationSize;
+
+ void cleanup()
+ {
+ // Unclean upload termination, be sure to erase the cached stat infos
+ Cache::self()->invalidateEntry(socket(), destinationFile.directory());
+ }
+
void process()
{
switch (currentState) {
case None: {
sourceFile.setPath(socket()->getConfig("params.get.source"));
destinationFile.setPath(socket()->getConfig("params.get.destination"));
+ fetchedSize = false;
// Check if the local file exists
if (!QDir::root().exists(sourceFile.path())) {
@@ -1695,8 +1705,6 @@
socket()->sendCommand("SIZE " + destinationFile.path());
} else {
// SIZE is not available, try stat directly
- Cache::self()->invalidateEntry(socket(), destinationFile.directory());
-
currentState = StatDone;
socket()->protoStat(destinationFile);
}
@@ -1704,18 +1712,16 @@
}
case SentSize: {
if (socket()->isResponse("213")) {
+ destinationSize = socket()->getResponse().mid(4).toULongLong();
+ fetchedSize = true;
+
// File exists, we have to stat to get more data
- Cache::self()->invalidateEntry(socket(), destinationFile.directory());
-
currentState = StatDone;
socket()->protoStat(destinationFile);
} else if (socket()->isResponse("500") || socket()->getResponse().contains("Operation not permitted", false)) {
// Yes, some servers don't support the SIZE command :/
socket()->setConfig("feat.size", 0);
- // Try stat instead
- Cache::self()->invalidateEntry(socket(), destinationFile.directory());
-
currentState = StatDone;
socket()->protoStat(destinationFile);
} else {
@@ -1726,6 +1732,17 @@
}
case StatDone: {
if (!socket()->getStatResponse().filename().isEmpty()) {
+ if (fetchedSize) {
+ if (socket()->getStatResponse().size() != destinationSize) {
+ // It would seem that the size has changed, cached data is invalid
+ Cache::self()->invalidateEntry(socket(), destinationFile.directory());
+
+ currentState = StatDone;
+ socket()->protoStat(destinationFile);
+ return;
+ }
+ }
+
// Remote file exists, emit a request for action
DirectoryListing list;
list.addEntry(socket()->getStatResponse());
@@ -1776,6 +1793,8 @@
}
case FileExistsWakeupEvent::Skip: {
// Transfer should be aborted
+ markClean();
+
socket()->resetCommandClass(UserAbort);
socket()->emitEvent(Event::EventTransferComplete);
return;
@@ -1806,6 +1825,7 @@
case WaitTransfer: {
// Transfer has been completed
socket()->getTransferFile()->close();
+ markClean();
socket()->emitEvent(Event::EventTransferComplete);
socket()->emitEvent(Event::EventReloadNeeded);
@@ -2175,6 +2195,10 @@
companion->setConfig("params.fxp.abort", 1);
companion->protoAbort();
}
+
+ // Unclean upload termination, be sure to erase the cached stat infos
+ if (!socket()->getConfigInt("params.fxp.keep_cache"))
+ Cache::self()->invalidateEntry(socket(), destinationFile.directory());
}
void process()
@@ -2183,6 +2207,7 @@
case None: {
sourceFile.setPath(socket()->getConfig("params.fxp.source"));
destinationFile.setPath(socket()->getConfig("params.fxp.destination"));
+ socket()->setConfig("params.fxp.keep_cache", 0);
// Who are we ? Where shall we begin ?
if (socket()->getConfigInt("params.fxp.companion")) {
@@ -2263,6 +2288,9 @@
}
case FileExistsWakeupEvent::Skip: {
// Transfer should be aborted
+ companion->setConfig("params.fxp.keep_cache", 1);
+ socket()->setConfig("params.fxp.keep_cache", 1);
+
socket()->resetCommandClass(UserAbort);
socket()->emitEvent(Event::EventTransferComplete);
return;
|