Author: jeremias
Date: Wed Feb 11 08:41:04 2009
New Revision: 743273
URL: http://svn.apache.org/viewvc?rev=743273&view=rev
Log:
Bugzilla #46686:
Use temporary directory for the font cache if the user home directory is not
write-accessible.
Submitted by: Alok Singh <alok.at.jivesoftware.com>
Modifications to patch by jeremias:
- Bugfix: original code switched to temporary directory if the .fop directory
already existed in user home.
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontCache.java
xmlgraphics/fop/trunk/status.xml
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontCache.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontCache.java?rev=743273&r1=743272&r2=743273&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontCache.java
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontCache.java Wed Feb
11 08:41:04 2009
@@ -81,11 +81,18 @@
}
private static File getUserHome() {
- String s = System.getProperty("user.home");
- if (s != null) {
- File userDir = new File(s);
- if (userDir.exists()) {
- return userDir;
+ return toDirectory(System.getProperty("user.home"));
+ }
+
+ private static File getTempDirectory() {
+ return toDirectory(System.getProperty("java.io.tmpdir"));
+ }
+
+ private static File toDirectory(String path) {
+ if (path != null) {
+ File dir = new File(path);
+ if (dir.exists()) {
+ return dir;
}
}
return null;
@@ -101,7 +108,15 @@
if (userHome != null) {
File fopUserDir = new File(userHome, FOP_USER_DIR);
if (forWriting) {
- fopUserDir.mkdir();
+ boolean writable = fopUserDir.canWrite();
+ if (!fopUserDir.exists()) {
+ writable = fopUserDir.mkdir();
+ }
+ if (!writable) {
+ userHome = getTempDirectory();
+ fopUserDir = new File(userHome, FOP_USER_DIR);
+ fopUserDir.mkdir();
+ }
}
return new File(fopUserDir, DEFAULT_CACHE_FILENAME);
}
Modified: xmlgraphics/fop/trunk/status.xml
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=743273&r1=743272&r2=743273&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Wed Feb 11 08:41:04 2009
@@ -58,6 +58,10 @@
documents. Example: the fix of marks layering will be such a case when
it's done.
-->
<release version="FOP Trunk" date="TBD">
+ <action context="Fonts" dev="JM" type="fix" fixes-bug="46686"
due-to="Alok Singh">
+ Use temporary directory for the font cache if the user home directory
is not
+ write-accessible.
+ </action>
<action context="Renderers" dev="JM" type="fix" fixes-bug="45342"
due-to="Emil Maskovsky">
AFP Fonts: Fixed interpretation of metric for fonts with fixed metrics
and made sure
all repeating groups in FNP (Font Position) are processed.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]