Revision: 6912
Author: sco...@google.com
Date: Mon Nov 16 09:48:58 2009
Log: Restore behavior where hosted mode linking will not overwrite a newer  
compiled selection script.

And generally, older resources won't overwrite newer ones.

Review by: spoon (desk)
http://code.google.com/p/google-web-toolkit/source/detail?r=6912

Modified:
  /trunk/dev/core/src/com/google/gwt/dev/util/NullOutputFileSet.java
  /trunk/dev/core/src/com/google/gwt/dev/util/OutputFileSetOnDirectory.java

=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/util/NullOutputFileSet.java  Tue  
Oct 27 18:11:59 2009
+++ /trunk/dev/core/src/com/google/gwt/dev/util/NullOutputFileSet.java  Mon  
Nov 16 09:48:58 2009
@@ -22,7 +22,7 @@
   * An {...@link OutputFileSet} that discards all data sent to it.
   */
  public class NullOutputFileSet extends OutputFileSet {
-  private static class NullOutputStream extends OutputStream {
+  static class NullOutputStream extends OutputStream {
      @Override
      public void write(byte[] b) throws IOException {
      }
=======================================
---  
/trunk/dev/core/src/com/google/gwt/dev/util/OutputFileSetOnDirectory.java       
 
Tue Oct 27 18:11:59 2009
+++  
/trunk/dev/core/src/com/google/gwt/dev/util/OutputFileSetOnDirectory.java       
 
Mon Nov 16 09:48:58 2009
@@ -15,6 +15,7 @@
   */
  package com.google.gwt.dev.util;

+import com.google.gwt.dev.util.NullOutputFileSet.NullOutputStream;
  import com.google.gwt.dev.util.collect.HashSet;

  import java.io.File;
@@ -42,14 +43,28 @@
    }

    @Override
-  public OutputStream openForWrite(String path, long lastModifiedTime)
+  public OutputStream openForWrite(String path, final long  
lastModifiedTime)
        throws IOException {
+    final File file = makeFileForPath(path);
+    if (file.exists() && file.lastModified() >= lastModifiedTime) {
+      return new NullOutputStream();
+    }
+    mkdirs(file.getParentFile());
+    return new FileOutputStream(file) {
+      @Override
+      public void close() throws IOException {
+        super.close();
+        file.setLastModified(lastModifiedTime);
+      }
+    };
+  }
+
+  private File makeFileForPath(String path) {
      File file = dir;
      for (String part : (prefix + path).split("/")) {
        file = new File(file, part);
      }
-    mkdirs(file.getParentFile());
-    return new FileOutputStream(file);
+    return file;
    }

    /**

-- 
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to