Bug 54051 - Wrong FontCache-Directory used for not existing userHome in FontCache.getDefaultCacheFile() (Bug 47786 was not fixed correctly)
Summary: Wrong FontCache-Directory used for not existing userHome in FontCache.getDefa...
Status: NEW
Alias: None
Product: Fop - Now in Jira
Classification: Unclassified
Component: fonts (show other bugs)
Version: 1.1
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: fop-dev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-25 12:09 UTC by mg
Modified: 2012-10-25 12:09 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mg 2012-10-25 12:09:59 UTC
Method getDefaultCacheFile() returns an invalid file name if the user has no home directory set. In that case the name of the fop user directory (FOP_USER_DIR!) is returned and not the name of the cache file (DEFAULT_CACHE_FILENAME).

Wrong Code:

    public static File getDefaultCacheFile(boolean forWriting) {
        File userHome = getUserHome();
        if (userHome != null) {
            File fopUserDir = new File(userHome, FOP_USER_DIR);
            if (forWriting) {
                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);
        }
        return new File(FOP_USER_DIR);
    }

If getUserHome() does not return a directory the default name must be returned (and not the name of the directory):

        return new File(DEFAULT_CACHE_FILENAME);