minor bug fix to avoid need for updating filesystem twice initially
This commit is contained in:
parent
4e1432af97
commit
4653778e8c
|
@ -108,26 +108,17 @@ public class SkyCoffeeFilesystem extends MoteInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateFS() {
|
private void updateFS() {
|
||||||
if (SwingUtilities.isEventDispatchThread()) {
|
|
||||||
/* Don't call me in EDT */
|
|
||||||
new Thread(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
updateFS();
|
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create new filesystem instance */
|
/* Create new filesystem instance */
|
||||||
try {
|
try {
|
||||||
SkyFlash flash = mote.getInterfaces().getInterfaceOfType(SkyFlash.class);
|
SkyFlash flash = mote.getInterfaces().getInterfaceOfType(SkyFlash.class);
|
||||||
coffeeFS = new CoffeeFS(flash.m24p80);
|
coffeeFS = new CoffeeFS(flash.m24p80);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
logger.fatal(e.getMessage(), e);
|
||||||
coffeeFS = null;
|
coffeeFS = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final CoffeeFile[] tmpFiles = coffeeFS.getFiles().values().toArray(new CoffeeFile[0]);
|
files = coffeeFS.getFiles().values().toArray(new CoffeeFile[0]);
|
||||||
for (CoffeeFile file : tmpFiles) {
|
for (CoffeeFile file : files) {
|
||||||
file.getName();
|
file.getName();
|
||||||
try {
|
try {
|
||||||
file.getLength();
|
file.getLength();
|
||||||
|
@ -137,8 +128,6 @@ public class SkyCoffeeFilesystem extends MoteInterface {
|
||||||
|
|
||||||
EventQueue.invokeLater(new Runnable() {
|
EventQueue.invokeLater(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
/* Update table */
|
|
||||||
files = tmpFiles;
|
|
||||||
((AbstractTableModel)filesTable.getModel()).fireTableDataChanged();
|
((AbstractTableModel)filesTable.getModel()).fireTableDataChanged();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -323,6 +312,7 @@ public class SkyCoffeeFilesystem extends MoteInterface {
|
||||||
|
|
||||||
public boolean insertFile(String diskFilename) {
|
public boolean insertFile(String diskFilename) {
|
||||||
try {
|
try {
|
||||||
|
updateFS();
|
||||||
return coffeeFS.insertFile(diskFilename) != null;
|
return coffeeFS.insertFile(diskFilename) != null;
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
logger.fatal("Error: " + e.getMessage(), e);
|
logger.fatal("Error: " + e.getMessage(), e);
|
||||||
|
|
Loading…
Reference in a new issue