40 // |
40 // |
41 void PartDownloader::staticBegin() |
41 void PartDownloader::staticBegin() |
42 { |
42 { |
43 QString path = getDownloadPath(); |
43 QString path = getDownloadPath(); |
44 |
44 |
45 if (path.isEmpty() || not QDir (path).exists()) |
45 if (path.isEmpty() or not QDir (path).exists()) |
46 { |
46 { |
47 critical (PartDownloader::tr ("You need to specify a valid path for " |
47 critical (PartDownloader::tr ("You need to specify a valid path for " |
48 "downloaded files in the configuration to download paths.")); |
48 "downloaded files in the configuration to download paths.")); |
49 |
49 |
50 (new ConfigDialog (ConfigDialog::DownloadTab, null))->exec(); |
50 (new ConfigDialog (ConfigDialog::DownloadTab, null))->exec(); |
131 { |
131 { |
132 // Remove the existing extension, if any. It may be we're here over a |
132 // Remove the existing extension, if any. It may be we're here over a |
133 // typo in the .dat extension. |
133 // typo in the .dat extension. |
134 const int dotpos = dest.lastIndexOf ("."); |
134 const int dotpos = dest.lastIndexOf ("."); |
135 |
135 |
136 if (dotpos != -1 && dotpos >= dest.length() - 4) |
136 if ((dotpos != -1) and (dotpos >= dest.length() - 4)) |
137 dest.chop (dest.length() - dotpos); |
137 dest.chop (dest.length() - dotpos); |
138 |
138 |
139 dest += ".dat"; |
139 dest += ".dat"; |
140 } |
140 } |
141 |
141 |
173 |
173 |
174 if (QRegExp (subpartRegex).exactMatch (dest)) |
174 if (QRegExp (subpartRegex).exactMatch (dest)) |
175 dest.prepend ("parts/s/"); |
175 dest.prepend ("parts/s/"); |
176 elif (QRegExp (partRegex).exactMatch (dest)) |
176 elif (QRegExp (partRegex).exactMatch (dest)) |
177 dest.prepend ("parts/"); |
177 dest.prepend ("parts/"); |
178 elif (not dest.startsWith ("parts/") && not dest.startsWith ("p/")) |
178 elif (not dest.startsWith ("parts/") and not dest.startsWith ("p/")) |
179 dest.prepend ("p/"); |
179 dest.prepend ("p/"); |
180 } |
180 } |
181 |
181 |
182 // ============================================================================= |
182 // ============================================================================= |
183 // |
183 // |
417 // |
417 // |
418 void PartDownloadRequest::downloadFinished() |
418 void PartDownloadRequest::downloadFinished() |
419 { |
419 { |
420 if (networkReply()->error() != QNetworkReply::NoError) |
420 if (networkReply()->error() != QNetworkReply::NoError) |
421 { |
421 { |
422 if (isPrimary() && not prompt()->isAborted()) |
422 if (isPrimary() and not prompt()->isAborted()) |
423 critical (networkReply()->errorString()); |
423 critical (networkReply()->errorString()); |
424 |
424 |
425 setState (DLRQ_Failed); |
425 setState (DLRQ_Failed); |
426 } |
426 } |
427 elif (state() != DLRQ_Failed) |
427 elif (state() != DLRQ_Failed) |
458 // it resolves dependencies. |
458 // it resolves dependencies. |
459 for (LDObjectPtr obj : f->objects()) |
459 for (LDObjectPtr obj : f->objects()) |
460 { |
460 { |
461 LDErrorPtr err = obj.dynamicCast<LDError>(); |
461 LDErrorPtr err = obj.dynamicCast<LDError>(); |
462 |
462 |
463 if (err == null || err->fileReferenced().isEmpty()) |
463 if ((err == null) or (err->fileReferenced().isEmpty())) |
464 continue; |
464 continue; |
465 |
465 |
466 QString dest = err->fileReferenced(); |
466 QString dest = err->fileReferenced(); |
467 prompt()->modifyDestination (dest); |
467 prompt()->modifyDestination (dest); |
468 prompt()->downloadFile (dest, g_unofficialLibraryURL + dest, false); |
468 prompt()->downloadFile (dest, g_unofficialLibraryURL + dest, false); |