Changeset 71a4b1


Ignore:
Timestamp:
Oct 15, 2014, 3:04:47 PM (6 years ago)
Author:
rene <rene@…>
Branches:
ng_0.9
Children:
d5349d
Parents:
079fc3
Message:

fix the delimiter issue (again:)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/vI_rdfDatasource.js

    r079fc3 r71a4b1  
    5151}
    5252
     53function initWithFilePath_tryDelimiters(_nsILocalFile, path, filename) {
     54    try {
     55        Log.debug("Filename try linux delimiter: '" + path + "/" + filename + "'");
     56        _nsILocalFile.initWithPath(path + "/" + filename);
     57    } catch (NS_ERROR_FILE_UNRECOGNIZED_PATH) {
     58        try {
     59            Log.debug("Filename try windows delimiter: '" + path + "\\" + filename + "'");
     60            _nsILocalFile.initWithPath(path + "\\" + filename);
     61        }
     62        catch (NS_ERROR_FILE_UNRECOGNIZED_PATH) {
     63            Log.debug("Filename not valid: '" + path + "[\\/]" + filename + "'");
     64            Log.debug("can't open rdfDatasource - storage won't work");
     65            var debugMsg = "Filename not valid: '" + path + "\\" + filename + "'\n" +
     66                "Filename not valid: '" + path + "/" + filename + "'\n" +
     67                "Virtual Identity Storage won't work.\n\n" +
     68                "Please report this issue with filename on https://www.absorb.it/virtual-id\n\n" +
     69                "You can just copy the lines below in your browser to create a ticket\n\n" +
     70                "https://www.absorb.it/virtual-id/newticket?summary=RDF Filename Error&description=Filename " + path + "[\\/]" + filename + " for rdf not valid"
     71            get3PaneWindow().alert(debugMsg);
     72            return;
     73        }
     74    }
     75};
     76
    5377rdfDatasource.prototype = {
    5478    _extVersion :       null,
     
    5882    _rdfDataSource :    null,
    5983    _rdfFileName :      null,
    60     _rdfDelimiter :     null,
    6184    _rdfNS :            "http://virtual-id.absorb.it/",
    6285    _rdfNSStorage :     "vIStorage",
     
    128151       
    129152//         Log.debug("_openRdfDataSource");
    130         try {
    131             Log.debug("Filename try linux delimiter: '" + file.path + "/" + this._rdfFileName + "'");
    132             newFile.initWithPath(file.path + "/" + this._rdfFileName);
    133 //             Log.debug("success");
    134             this._rdfDelimiter = "/";
    135         } catch (NS_ERROR_FILE_UNRECOGNIZED_PATH) {
    136             try {
    137                 Log.debug("Filename try windows delimiter: '" + file.path + "\\" + this._rdfFileName + "'");
    138                 newFile.initWithPath(file.path + "\\" + this._rdfFileName);
    139 //                 Log.debug("success");
    140                 this._rdfDelimiter = "\\";
    141             }
    142             catch (NS_ERROR_FILE_UNRECOGNIZED_PATH) {
    143                 Log.debug("Filename not valid: '" + file.path + "[\\/]" + this._rdfFileName + "'");
    144                 Log.debug("can't open rdfDatasource - storage won't work");
    145                 var debugMsg = "Filename not valid: '" + file.path + "\\" + this._rdfFileName + "'\n" +
    146                     "Filename not valid: '" + file.path + "/" + this._rdfFileName + "'\n" +
    147                     "Virtual Identity Storage won't work.\n\n" +
    148                     "Please report this issue with filename on https://www.absorb.it/virtual-id\n\n" +
    149                     "You can just copy the lines below in your browser to create a ticket\n\n" +
    150                     "https://www.absorb.it/virtual-id/newticket?summary=RDF Filename Error&description=Filename " + file.path + "[\\/]" + this._rdfFileName + " for rdf not valid"
    151                 get3PaneWindow().alert(debugMsg);
    152                 return;
    153             }
    154         }
     153        initWithFilePath_tryDelimiters(newFile, file.path, this._rdfFileName);
     154       
    155155        var fileURI = protoHandler.newFileURI(newFile);
    156156
     
    425425            var found = false;
    426426            var accounts = getAccountsArray();
     427            var identity = null;
    427428            for (let acc = 0; acc < accounts.length; acc++) {
    428429                let account = accounts[acc];
    429430                let identities = getIdentitiesArray(account);
    430431                for (let i = 0; i < identities.length; i++) {
    431                     let identity = identities[i];
     432                    identity = identities[i];
    432433                    if (id == identity.key) { found = true; break; }
    433434                }
     
    579580
    580581    export : function(rdfFileName) {
     582        Log.debug("vI_rdfDatasource export: " + rdfFileName + "\n");
    581583        var filePicker = Components.classes["@mozilla.org/filepicker;1"]
    582584            .createInstance(Components.interfaces.nsIFilePicker);
     
    590592            var file = Components.classes["@mozilla.org/file/directory_service;1"]
    591593                .getService(Components.interfaces.nsIProperties).get("ProfD", Components.interfaces.nsIFile);
    592             rdfDataFile.initWithPath(file.path + this._rdfDelimiter + rdfFileName);
    593 
     594               
     595            initWithFilePath_tryDelimiters(rdfDataFile, file.path, rdfFileName);
    594596            rdfDataFile.copyTo(filePicker.file.parent,filePicker.file.leafName);
    595597        }
     
    11511153            var file = Components.classes["@mozilla.org/file/directory_service;1"]
    11521154                .getService(Components.interfaces.nsIProperties).get("ProfD", Components.interfaces.nsIFile);
    1153             importRdfDataFile.initWithPath(file.path + this._rdfDelimiter + this._rdfFileName + "_import");
     1155               
     1156            initWithFilePath_tryDelimiters(importRdfDataFile, file.path, this._rdfFileName + "_import");
    11541157            filePicker.file.copyTo(importRdfDataFile.parent,importRdfDataFile.leafName);
    11551158
Note: See TracChangeset for help on using the changeset viewer.