Kaynağa Gözat

Merge branch 'dev-xym-log' of Server/long-article-manage into master

xueyiming 1 ay önce
ebeveyn
işleme
60d4aaa9f4

+ 2 - 1
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/utils/other/VideoDownloader.java

@@ -101,6 +101,7 @@ public class VideoDownloader {
 
             int responseCode = connection.getResponseCode();
             if (responseCode == HttpURLConnection.HTTP_OK || responseCode == HttpURLConnection.HTTP_PARTIAL) {
+                long expectedSize = connection.getContentLengthLong();
                 try (InputStream inputStream = connection.getInputStream();
                      OutputStream outputStream = Files.newOutputStream(file.toPath())) {
                     byte[] buffer = new byte[1024 * 1024];
@@ -116,7 +117,7 @@ public class VideoDownloader {
                         }
                     }
                 }
-                if (file.length() != 0) {
+                if (file.length() != expectedSize) {
                     return 0;
                 }
             }