comparison src/org/tmatesoft/hg/util/RegularFileStats.java @ 476:c02b5710d9ac

Defect: only first file in directory got flags initialized
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 12 Jul 2012 18:07:12 +0200
parents 909306e412e2
children 661e77dc88ba
comparison
equal deleted inserted replaced
475:0e34b8f3946a 476:c02b5710d9ac
106 // perhaps, shall just collect stats for all files and set false to exec/link flags? 106 // perhaps, shall just collect stats for all files and set false to exec/link flags?
107 throw new IllegalArgumentException(); 107 throw new IllegalArgumentException();
108 } 108 }
109 final String dirName = f.getParentFile().getAbsolutePath(); 109 final String dirName = f.getParentFile().getAbsolutePath();
110 final String fileName = f.getName(); 110 final String fileName = f.getName();
111 Map<String, String> links = dir2links.get(dirName); 111 try {
112 Set<String> execs = dir2execs.get(dirName); 112 Map<String, String> links = dir2links.get(dirName);
113 if (links == null || execs == null) { 113 Set<String> execs = dir2execs.get(dirName);
114 try { 114 if (links == null || execs == null) {
115 ArrayList<String> cmd = new ArrayList<String>(command); 115 ArrayList<String> cmd = new ArrayList<String>(command);
116 cmd.add(dirName); 116 cmd.add(dirName);
117 CharSequence result = execHelper.exec(cmd); 117 CharSequence result = execHelper.exec(cmd);
118 118
119 if (execMatcher.reset(result).find()) { 119 if (execMatcher.reset(result).find()) {
132 } else { 132 } else {
133 links = Collections.emptyMap(); 133 links = Collections.emptyMap();
134 } 134 }
135 dir2links.put(dirName, links); 135 dir2links.put(dirName, links);
136 dir2execs.put(dirName, execs); 136 dir2execs.put(dirName, execs);
137 isExec = execs.contains(fileName);
138 isSymlink = links.containsKey(fileName);
139 if (isSymlink) {
140 symlinkValue = links.get(fileName);
141 } else {
142 symlinkValue = null;
143 }
144 } catch (InterruptedException ex) {
145 sessionContext.getLog().dump(getClass(), Warn, ex, String.format("Failed to detect flags for %s", f));
146 // try again? ensure not too long? stop right away?
147 // IGNORE, keep isExec and isSymlink false
148 } catch (IOException ex) {
149 sessionContext.getLog().dump(getClass(), Warn, ex, String.format("Failed to detect flags for %s", f));
150 // IGNORE, keep isExec and isSymlink false
151 } 137 }
138 isExec = execs.contains(fileName);
139 isSymlink = links.containsKey(fileName);
140 if (isSymlink) {
141 symlinkValue = links.get(fileName);
142 } else {
143 symlinkValue = null;
144 }
145 } catch (InterruptedException ex) {
146 sessionContext.getLog().dump(getClass(), Warn, ex, String.format("Failed to detect flags for %s", f));
147 // try again? ensure not too long? stop right away?
148 // IGNORE, keep isExec and isSymlink false
149 } catch (IOException ex) {
150 sessionContext.getLog().dump(getClass(), Warn, ex, String.format("Failed to detect flags for %s", f));
151 // IGNORE, keep isExec and isSymlink false
152 } 152 }
153 } 153 }
154 154
155 public boolean isExecutable() { 155 public boolean isExecutable() {
156 return isExec; 156 return isExec;
157 } 157 }
158 158