import java.io.File;
import java.io.IOException;
import java.net.URL;
+import java.util.ArrayList;
import java.util.List;
import be.nikiroo.fanfix.Instance;
import be.nikiroo.fanfix.bundles.UiConfig;
+import be.nikiroo.fanfix.bundles.UiConfigBundle;
import be.nikiroo.fanfix.data.MetaData;
import be.nikiroo.fanfix.data.Story;
+import be.nikiroo.fanfix.output.BasicOutput.OutputType;
import be.nikiroo.utils.Image;
import be.nikiroo.utils.Progress;
/**
* Create a cache library around the given one.
* <p>
- * It will return the same result, but those will be saved to disk at the
- * same time to be fetched quicker the next time.
+ * It will return the same result, but those will be saved to disk at the same
+ * time to be fetched quicker the next time.
*
- * @param cacheDir
- * the cache directory where to save the files to disk
- * @param lib
- * the original library to wrap
+ * @param cacheDir the cache directory where to save the files to disk
+ * @param lib the original library to wrap
+ * @param config the configuration used to know which kind of default
+ * {@link OutputType} to use for images and non-images stories
*/
- public CacheLibrary(File cacheDir, BasicLibrary lib) {
- this.cacheLib = new LocalLibrary(cacheDir, Instance.getUiConfig()
- .getString(UiConfig.GUI_NON_IMAGES_DOCUMENT_TYPE), Instance
- .getUiConfig().getString(UiConfig.GUI_IMAGES_DOCUMENT_TYPE),
- true);
+ public CacheLibrary(File cacheDir, BasicLibrary lib, UiConfigBundle config) {
+ this.cacheLib = new LocalLibrary(cacheDir, //
+ config.getString(UiConfig.GUI_NON_IMAGES_DOCUMENT_TYPE),
+ config.getString(UiConfig.GUI_IMAGES_DOCUMENT_TYPE), true);
this.lib = lib;
}
}
pg.done();
- return metas;
+ return new ArrayList<MetaData>(metas);
}
@Override
updateInfo(cacheLib.getInfo(luid));
pgImport.done();
} catch (IOException e) {
- Instance.getTraceHandler().error(e);
+ Instance.getInstance().getTraceHandler().error(e);
}
pgImport.done();
invalidateInfo(luid);
}
- /**
- * Check if the {@link Story} denoted by this Library UID is present in the
- * cache.
- *
- * @param luid
- * the Library UID
- *
- * @return TRUE if it is
- */
+ @Override
public boolean isCached(String luid) {
try {
return cacheLib.getInfo(luid) != null;
}
}
- /**
- * Clear the {@link Story} from the cache.
- * <p>
- * The next time we try to retrieve the {@link Story}, it may be required to
- * cache it again.
- *
- * @param luid
- * the story to clear
- *
- * @throws IOException
- * in case of I/O error
- */
+ @Override
public void clearFromCache(String luid) throws IOException {
if (isCached(luid)) {
cacheLib.delete(luid);