This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 269778
Collapse All | Expand All

(-)a/dlight.remote.impl/src/org/netbeans/modules/remote/impl/fs/DirectoryStorage.java (-30 / +34 lines)
Lines 166-203 Link Here
166
            RemoteLogger.assertTrueInConsole(false, "Storage has been unexpectedly deleted: " + cacheFile.getAbsolutePath()); //NOI18N
166
            RemoteLogger.assertTrueInConsole(false, "Storage has been unexpectedly deleted: " + cacheFile.getAbsolutePath()); //NOI18N
167
        }
167
        }
168
    }
168
    }
169
    
169
170
    static void store(File cacheFile, Collection<DirEntry> entries) throws IOException {
171
        BufferedWriter wr = null;
172
        try {
173
            wr = Files.newBufferedWriter(cacheFile.toPath(), Charset.forName("UTF-8")); //NOI18N 
174
            wr.write("VERSION=" + VERSION + "\n"); //NOI18N
175
            Collection<DirEntry> invalid = new ArrayList<>();
176
            Collection<DirEntry> valid = new ArrayList<>();
177
            for (DirEntry entry : entries) {
178
                if (entry.isValid()) {
179
                    valid.add(entry);
180
                } else {
181
                    invalid.add(entry);
182
                }
183
            }                
184
            wr.write("dummies=" + invalid.size() + '\n'); //NOI18N
185
            for (DirEntry entry: invalid) {
186
                wr.write(entry.toExternalForm());
187
                wr.write('\n');
188
            }
189
            for (DirEntry entry : valid) {
190
                wr.write(entry.toExternalForm());
191
                wr.write('\n');
192
            }
193
            wr.close();
194
            wr = null;
195
        } finally {
196
            if (wr != null) {
197
                wr.close();
198
            }
199
        }
200
    }
201
        
170
    public void store() throws IOException {
202
    public void store() throws IOException {
171
        BufferedWriter wr = null;
172
        synchronized (this) {
203
        synchronized (this) {
173
            try {
204
            store(cacheFile, entries.values());
174
                wr = Files.newBufferedWriter(cacheFile.toPath(), Charset.forName("UTF-8")); //NOI18N 
175
                wr.write("VERSION=" + VERSION + "\n"); //NOI18N
176
                Collection<DirEntry> invalid = new ArrayList<>();
177
                Collection<DirEntry> valid = new ArrayList<>();
178
                for (DirEntry entry : entries.values()) {                   
179
                    if (entry.isValid()) {
180
                        valid.add(entry);
181
                    } else {
182
                        invalid.add(entry);
183
                    }
184
                }                
185
                wr.write("dummies=" + invalid.size() + '\n'); //NOI18N
186
                for (DirEntry entry: invalid) {
187
                    wr.write(entry.toExternalForm());
188
                    wr.write('\n');
189
                }
190
                for (DirEntry entry : valid) {
191
                    wr.write(entry.toExternalForm());
192
                    wr.write('\n');
193
                }
194
                wr.close();
195
                wr = null;
196
            } finally {
197
                if (wr != null) {
198
                    wr.close();
199
                }
200
            }
201
        }
205
        }
202
    }
206
    }
203
207
(-)a/dlight.remote.impl/src/org/netbeans/modules/remote/impl/fs/RemoteDirectory.java (-3 / +13 lines)
Lines 1568-1579 Link Here
1568
                        }
1568
                        }
1569
                    }
1569
                    }
1570
                }
1570
                }
1571
                uploadAndUnzip(zipFile);
1571
                uploadAndUnzip(zipFile);                
1572
            } finally {
1572
            } finally {
1573
                zipFile.delete();
1573
                zipFile.delete();
1574
                this.refresh(true);
1574
                this.refresh(true);
1575
            }
1575
            }
1576
        } finally {
1576
        } finally {
1577
            for (RemoteFileObjectBase fo : suspendInfo.getAllSuspended()) {
1578
                fo.setFlag(MASK_SUSPENDED_DUMMY, false);
1579
            }
1577
            suspendInfo.dispose();
1580
            suspendInfo.dispose();
1578
        }
1581
        }
1579
    }
1582
    }
Lines 1635-1644 Link Here
1635
        }
1638
        }
1636
        getCache().mkdirs();
1639
        getCache().mkdirs();
1637
        try (InputStream is = new FileInputStream(localZipFile)) {
1640
        try (InputStream is = new FileInputStream(localZipFile)) {
1638
            RemoteFileSystemUtils.unpackZipFile(is, getCache());
1641
            Set<File> dirs = new HashSet<>();
1642
            RemoteFileSystemUtils.unpackZipFile(is, getCache(), dirs);
1643
            for (File dir : dirs) {
1644
                File cache = new File(dir, RemoteFileSystem.CACHE_FILE_NAME);
1645
                if (!cache.exists()) {
1646
                    DirectoryStorage.store(cache, Collections.<DirEntry>emptyList());
1647
                };
1648
            }
1639
        }
1649
        }
1640
        try {
1650
        try {
1641
            refreshImpl(trace, null, true, RefreshMode.DEFAULT, 0);
1651
            refreshImpl(true, null, true, RefreshMode.DEFAULT, 0);
1642
        } catch (TimeoutException ex) {
1652
        } catch (TimeoutException ex) {
1643
            RemoteFileSystemUtils.reportUnexpectedTimeout(ex, this);
1653
            RemoteFileSystemUtils.reportUnexpectedTimeout(ex, this);
1644
        } catch (ExecutionException ex) {
1654
        } catch (ExecutionException ex) {
(-)a/dlight.remote.impl/src/org/netbeans/modules/remote/impl/fs/RemoteFileSystemUtils.java (-1 / +5 lines)
Lines 50-55 Link Here
50
import java.io.OutputStream;
50
import java.io.OutputStream;
51
import java.util.ArrayList;
51
import java.util.ArrayList;
52
import java.util.List;
52
import java.util.List;
53
import java.util.Set;
53
import java.util.concurrent.ExecutionException;
54
import java.util.concurrent.ExecutionException;
54
import java.util.concurrent.TimeoutException;
55
import java.util.concurrent.TimeoutException;
55
import java.util.logging.Level;
56
import java.util.logging.Level;
Lines 400-406 Link Here
400
     * @param dir the base directory in which to unpack (need not yet exist)
401
     * @param dir the base directory in which to unpack (need not yet exist)
401
     * @throws IOException in case of problems
402
     * @throws IOException in case of problems
402
     */
403
     */
403
    public static void unpackZipFile(InputStream zipStream, File dir) throws IOException {
404
    public static void unpackZipFile(InputStream zipStream, File dir, Set<File> createdDirs) throws IOException {
404
        byte[] buf = new byte[8192];
405
        byte[] buf = new byte[8192];
405
        ZipInputStream zis = new ZipInputStream(zipStream);
406
        ZipInputStream zis = new ZipInputStream(zipStream);
406
        ZipEntry entry;
407
        ZipEntry entry;
Lines 412-417 Link Here
412
                if (!baseDir.isDirectory() && !baseDir.mkdirs()) {
413
                if (!baseDir.isDirectory() && !baseDir.mkdirs()) {
413
                    throw new IOException("could not make " + baseDir); // NOI18N
414
                    throw new IOException("could not make " + baseDir); // NOI18N
414
                }
415
                }
416
                if (createdDirs != null) {
417
                    createdDirs.add(baseDir);
418
                }
415
            }                
419
            }                
416
            if (slash != name.length() - 1) {
420
            if (slash != name.length() - 1) {
417
                File f = new File(dir, name.replace('/', File.separatorChar));
421
                File f = new File(dir, name.replace('/', File.separatorChar));

Return to bug 269778