src/hg/lib/jsHelper.c 1.28

1.28 2009/07/08 19:48:54 larrym
errAbort if we can't create symlinks in js directory
Index: src/hg/lib/jsHelper.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/lib/jsHelper.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -b -B -U 4 -r1.27 -r1.28
--- src/hg/lib/jsHelper.c	8 Jul 2009 17:09:51 -0000	1.27
+++ src/hg/lib/jsHelper.c	8 Jul 2009 19:48:54 -0000	1.28
@@ -27,9 +27,8 @@
 
 static boolean jsInited = FALSE;
 static boolean defaultWarningShown = FALSE;
 struct hash *includedFiles = NULL;
-boolean symlinkFailed = FALSE;    // true when we can't create symlinks in js directory
 
 void jsInit()
 /* If this is the first call, set window.onload to the operations
  * performed upon loading a page and print supporting javascript.
@@ -360,20 +359,21 @@
         dyStringPrintf(fullDirName, "%s/%s", docRoot, dirName);
         if(fileExists(dyStringContents(fullDirName)))
             {
             struct dyString *realFileName = dyStringNew(0);
+            struct dyString *fullNameWithVersion = dyStringNew(0);
+            long mtime;
+            
             dyStringPrintf(realFileName, "%s/%s", dyStringContents(fullDirName), fileName);
             if(!fileExists(dyStringContents(realFileName)))
                 {
                 errAbort("jsIncludeFile: javascript file: %s doesn't exist.\n", dyStringContents(realFileName));
                 }
-            if(!symlinkFailed)
-                {
+            mtime = fileModTime(dyStringContents(realFileName));
+
                 // we add mtime to create a pseudo-version; this forces browsers to reload js file when it changes,
                 // which fixes bugs and odd behavior that occurs when the browser caches modified js files
 
-                long mtime = fileModTime(dyStringContents(realFileName));
-                struct dyString *fullNameWithVersion = dyStringNew(0);
                 dyStringPrintf(fileNameWithVersion, "%s-%ld.js", baseName, mtime);
                 dyStringPrintf(fullNameWithVersion, "%s/%s", dyStringContents(fullDirName), dyStringContents(fileNameWithVersion));
                 if(!fileExists(dyStringContents(fullNameWithVersion)))
                     {
@@ -392,19 +392,13 @@
                     slFreeList(&files);
                     dyStringFree(&pattern);
                     if(symlink(dyStringContents(realFileName), dyStringContents(fullNameWithVersion)))
                         {
-                        // We do not report failed creation of symlinks b/c I think it will be common in mirrors for the
-                        // www user to not have write permission to the js directory. When this happens,
-                        // we fall back to using non-versioned javascript references
-
-                        // fprintf(stderr, "jsIncludeFile: symlink failed: errno: %d (%s)\n", errno, strerror(errno));
-                        symlinkFailed = TRUE;
-                        dyStringClear(fileNameWithVersion);
+                    errAbort("jsIncludeFile: symlink failed: errno: %d (%s); the directory '%s' must be writeable by user '%s'\n", 
+                             errno, strerror(errno), dyStringContents(fullDirName), getUser());
                         }
                     }
                 dyStringFree(&fullNameWithVersion);
-                }
             dyStringFree(&fullDirName);
             }
         else
             {