lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

lynx-dev [PATCH] SOURCE_CACHE_FOR_ABORTED


From: Vlad Harchev
Subject: lynx-dev [PATCH] SOURCE_CACHE_FOR_ABORTED
Date: Thu, 20 Apr 2000 12:45:06 +0500 (SAMST)

* Initial support for SOURCE_CACHE_FOR_ABORTED was added.

 Currently, only two values are supported - DROP (default) and KEEP. It seemed
to me that other values (PREVIOUS_OR_OK, PREVIOUS_OR_DROP) would require some
AI and will only confuse user when previous cache entry is also from 
interupted downloading (i.e. "which one to use" question is very difficult to
answer).
 For those who still prefer to nest options like this under SOURCE_CACHE: I
think I will submit a patch that will allow downloading from source cache 
sometime (but I don't think we should include it in -pre branch) - so there
will be one more lynx.cfg option (treat this as my argument against syntax
of the form "FOO:A,B").

 Best regards,
  -Vlad
diff -ru lynx2-8-3-was/lynx.cfg lynx2-8-3/lynx.cfg
--- lynx2-8-3-was/lynx.cfg      Mon Mar 27 08:14:00 2000
+++ lynx2-8-3/lynx.cfg  Thu Apr 20 12:35:08 2000
@@ -692,6 +692,15 @@
 #
 #SOURCE_CACHE:NONE
 
+.h2 SOURCE_CACHE_FOR_ABORTED
+# This setting controls what will happen with cached source for the document
+# being fetched from the net if fetching was aborted (either user pressed 
+# 'z' or network went down). If set to KEEP, the source fetched so far will
+# be preserved (and used as cache), if set to DROP lynx will drop the 
+# source cache for that document (i.e. only completely downloaded documents 
+# will be cached in that case).
+#SOURCE_CACHE_FOR_ABORTED:DROP
+
 .h2 ALWAYS_RESUBMIT_POSTS
 # If ALWAYS_RESUBMIT_POSTS is set TRUE, Lynx always will resubmit forms
 # with method POST, dumping any cache from a previous submission of the
diff -ru lynx2-8-3-was/src/GridText.c lynx2-8-3/src/GridText.c
--- lynx2-8-3-was/src/GridText.c        Mon Mar 27 08:14:00 2000
+++ lynx2-8-3/src/GridText.c    Thu Apr 20 12:09:34 2000
@@ -133,6 +133,7 @@
 
 #ifdef SOURCE_CACHE
 PUBLIC int LYCacheSource = SOURCE_CACHE_NONE;
+PUBLIC int LYCacheSourceForAborted = SOURCE_CACHE_FOR_ABORTED_DROP;
 #endif
 
 #ifdef USE_SCROLLBAR
diff -ru lynx2-8-3-was/src/HTML.c lynx2-8-3/src/HTML.c
--- lynx2-8-3-was/src/HTML.c    Mon Mar 27 08:14:00 2000
+++ lynx2-8-3/src/HTML.c        Thu Apr 20 12:18:18 2000
@@ -8401,7 +8401,7 @@
  * Pass-thru cache HTStream
  */
 
-PRIVATE void CacheThru_free ARGS1(
+PRIVATE void CacheThru_do_free ARGS1(
        HTStream *,     me)
 {
     if (me->anchor->source_cache_file) {
@@ -8449,6 +8449,12 @@
                "SourceCacheWriter: Committing memory chunk %p for URL %s to 
anchor\n",
                (void *)me->chunk, HTAnchor_address((HTAnchor *)me->anchor)));
     }
+}
+
+PRIVATE void CacheThru_free ARGS1(
+       HTStream *,     me)
+{
+    CacheThru_do_free(me);
     (*me->actions->_free)(me->target);
     FREE(me);
 }
@@ -8459,17 +8465,22 @@
 {
     if (me->fp)
        LYCloseTempFP(me->fp);
-    if (me->filename) {
-       CTRACE((tfp, "SourceCacheWriter: Removing active file %s\n",
-               me->filename));
-       LYRemoveTemp(me->filename);
-       FREE(me->filename);
-    }
-    if (me->chunk) {
-       CTRACE((tfp, "SourceCacheWriter: Removing active memory chunk %p\n",
-               (void *)me->chunk));
-       HTChunkFree(me->chunk);
-    }
+    if (LYCacheSourceForAborted==SOURCE_CACHE_FOR_ABORTED_DROP) {
+       if (me->filename) {
+           CTRACE((tfp, "SourceCacheWriter: Removing active file %s\n",
+                   me->filename));
+           LYRemoveTemp(me->filename);
+           FREE(me->filename);
+       }
+       if (me->chunk) {
+           CTRACE((tfp, "SourceCacheWriter: Removing active memory chunk %p\n",
+                   (void *)me->chunk));
+           HTChunkFree(me->chunk);
+       }
+    } else {
+       me->status = HT_OK;/*fake it*/
+       CacheThru_do_free(me);
+    };
     (*me->actions->_abort)(me->target, e);
     FREE(me);
 }
diff -ru lynx2-8-3-was/src/LYGlobalDefs.h lynx2-8-3/src/LYGlobalDefs.h
--- lynx2-8-3-was/src/LYGlobalDefs.h    Mon Mar 27 08:14:00 2000
+++ lynx2-8-3/src/LYGlobalDefs.h        Thu Apr 20 12:27:31 2000
@@ -306,6 +306,10 @@
 #define SOURCE_CACHE_NONE      0
 #define SOURCE_CACHE_FILE      1
 #define SOURCE_CACHE_MEMORY    2
+
+extern int LYCacheSourceForAborted;
+#define SOURCE_CACHE_FOR_ABORTED_KEEP 1
+#define SOURCE_CACHE_FOR_ABORTED_DROP 0
 #endif
 extern BOOLEAN LYCancelDownload;
 extern BOOLEAN LYRestricted;   /* whether we had -anonymous option */
diff -ru lynx2-8-3-was/src/LYReadCFG.c lynx2-8-3/src/LYReadCFG.c
--- lynx2-8-3-was/src/LYReadCFG.c       Mon Mar 27 08:14:00 2000
+++ lynx2-8-3/src/LYReadCFG.c   Thu Apr 20 12:08:30 2000
@@ -948,6 +948,7 @@
     static Config_Enum table[] = {
        { "FILE",       SOURCE_CACHE_FILE },
        { "MEM",        SOURCE_CACHE_MEMORY },
+       { "MEMORY",     SOURCE_CACHE_MEMORY },  
        { "NONE",       SOURCE_CACHE_NONE },
        { NULL,         SOURCE_CACHE_NONE },
     };
@@ -955,6 +956,18 @@
 
     return 0;
 }
+
+static int source_cache_for_aborted_fun ARGS1(
+       char *,         value)
+{
+    static Config_Enum table[] = {
+       { "KEEP",       SOURCE_CACHE_FOR_ABORTED_KEEP },
+       { "DROP",       SOURCE_CACHE_FOR_ABORTED_DROP },
+       { NULL,         SOURCE_CACHE_FOR_ABORTED_DROP },
+    };
+    LYCacheSourceForAborted = config_enum(table, value);
+    return 0;
+}
 #endif
 
 static int suffix_fun ARGS1(
@@ -1531,6 +1544,7 @@
      PARSE_SET("soft_dquotes", CONF_BOOL, &soft_dquotes),
 #ifdef SOURCE_CACHE
      PARSE_SET("source_cache", CONF_FUN, source_cache_fun),
+     PARSE_SET("source_cache_for_aborted",CONF_FUN, 
source_cache_for_aborted_fun),
 #endif
      PARSE_STR("startfile", CONF_STR, &startfile),
      PARSE_SET("strip_dotdot_urls", CONF_BOOL, &LYStripDotDotURLs),


reply via email to

[Prev in Thread] Current Thread [Next in Thread]