Skip to content

Commit

Permalink
Merge branch 'Bugfix-3.4.1' into 'master'
Browse files Browse the repository at this point in the history
Bugfix 3.4.1

Closes nextcloud#73, nextcloud#86, nextcloud#85, and nextcloud#81

See merge request joendres/filelink-nextcloud!48
  • Loading branch information
joendres committed Feb 21, 2020
2 parents 83847df + f19cea2 commit d36999f
Show file tree
Hide file tree
Showing 15 changed files with 140 additions and 79 deletions.
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
],
"cSpell.language": "de,en",
"cSpell.allowCompoundWords": true,
"git.alwaysSignOff": true,
"git.fetchOnPull": true,
"git.untrackedChanges": "separate"
"git.untrackedChanges": "separate",
"gitlab.enableExperimentalFeatures": true,
"gitlab.showPipelineUpdateNotifications": true
}
14 changes: 14 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@
}
},
"problemMatcher": []
},
{
"label": "web-ext: run in thunderbird, keep profile changes",
"type": "shell",
"command": "web-ext run --browser-console --keep-profile-changes -s src",
"windows": {
"options": {
"env": {
"WEB_EXT_FIREFOX": "C:\\Program Files\\Mozilla Thunderbird\\thunderbird.exe",
"WEB_EXT_FIREFOX_PROFILE": "${env:APPDATA}\\Thunderbird\\Profiles\\plyesg2i.debug"
}
}
},
"problemMatcher": []
}
]
}
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
3.4.1 2020-02-21
- Close #81: French translation of new messages
- Close #82: Catalan and spanish translations of new messages
- Close #73: Shows outdated free space info while editing account
- Internal Project optimization & cleanup in davuploader

3.4.0 2020-02-18
- Close #27: Show Nextcloud/ownCloud flavor and version
- Close #70: Show product name instead of account name
Expand Down
3 changes: 1 addition & 2 deletions src/.jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@
"strict": "implied",
"trailingcomma": true,
"undef": true,
"unused": true,
"-W098": true
"unused": true
}
13 changes: 13 additions & 0 deletions src/_locales/ca/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,18 @@
},
"error_0": {
"message": "Error desconegut"
},
"error_cloud_unreachable": {
"message": "Sense connexió. Comprova la URL del servidor i la connexió de xarxa."
},
"error_no_cloud": {
"message": "No trobo un núvol compatible a la URL donada."
},
"unsupported_cloud": {
"message": "Versió obsoleta de Nextcloud o ownCloud. Pots perdre dades. Contacta el teu administrador per actualitzar."
},
"obsolete_version": {
"description": "This is displayed instead of the icon if the cloud version is not supported, so it should be quite short and contain exactly two lines.",
"message": "Versió<br>obsoleta"
}
}
13 changes: 13 additions & 0 deletions src/_locales/es/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,18 @@
},
"error_0": {
"message": "Error desconocido"
},
"error_cloud_unreachable": {
"message": "Sin conexión. Comprueba la URL del servidor y la conexión de red."
},
"error_no_cloud": {
"message": "No encuentro una nube compatible en la URL."
},
"unsupported_cloud": {
"message": "Versión obsoleta de Nextcloud o ownCloud. Puedes perder datos. Contacta con tu administrador para actualizar."
},
"obsolete_version": {
"description": "This is displayed instead of the icon if the cloud version is not supported, so it should be quite short and contain exactly two lines.",
"message": "Versión<br>obsoleta"
}
}
21 changes: 20 additions & 1 deletion src/_locales/fr/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,24 @@
"content": "$2"
}
}
},
"success": {
"message": "Réussi"
},
"error_0": {
"message": "Erreur inconnue"
},
"error_cloud_unreachable": {
"message": "Connexion impossible. Veuillez vérifier votre connexion internet et l'adresse de votre serveur."
},
"error_no_cloud": {
"message": "Aucun serveur Cloud compatible trouvé avec cette adresse."
},
"unsupported_cloud": {
"message": "Attention, la version d'ownCloud ou Nextcloud que vous utilisez est obsolète. Si vous continuez, vous risquez de perdre des données. Contactez l'administrateur de votre serveur pour une mise à jour."
},
"obsolete_version": {
"description": "This is displayed instead of the icon if the cloud version is not supported, so it should be quite short and contain exactly two lines.",
"message": "Version<br>obsolète"
}
}
}
20 changes: 10 additions & 10 deletions src/lib/davuploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */

/* global encodepath */
/* exported DavUploader */

/** AbortControllers for all active uploads */
var allAbortControllers = new Map();
Expand Down Expand Up @@ -59,10 +60,9 @@ class DavUploader {
* @param {number} fileId The id Thunderbird uses to reference the upload
* @param {string} fileName w/o path
* @param {File} fileObject the local file as a File object
* @returns {Promise<Response>}
*/
async uploadFile(fileId, fileName, fileObject) {
let response = {};

const stat = await this._getRemoteFileInfo(fileName);

if (!stat) {
Expand All @@ -87,15 +87,15 @@ class DavUploader {
* Create a complete folder path, returns true if that path already exists
*
* @param {string} folder
* @returns {bool} if creation succeeded
* @returns {boolean} if creation succeeded
*/
async _recursivelyCreateFolder(folder) {
// Looks clumsy, but *always* make sure recursion ends
if ("/" === folder) {
return false;
} else {
let response = await this._doDavCall(folder, 'MKCOL')
.catch(e => { return { status: 666, }; });
.catch(() => ({ status: 666, }));
switch (response.status) {
case 405: // Already exists
case 201: // Created successfully
Expand All @@ -105,7 +105,7 @@ class DavUploader {
if (await this._recursivelyCreateFolder(folder.split("/").slice(0, -1).join("/"))) {
// Try again to create the initial folder
response = await this._doDavCall(folder, 'MKCOL')
.catch(e => { return { status: 666, }; });
.catch(() => ({ status: 666, }));
return (201 === response.status);
}
break;
Expand All @@ -117,7 +117,7 @@ class DavUploader {
/**
* Fetches information about a remote file
* @param {File} file The file to check on the cloud
* @returns {Promise} A promise resolving to an object containing mtime and
* @returns {Promise<?{mtime: Date, size: number}} A promise resolving to an object containing mtime and
* size or an empty object if the file doesn't exit
*/
async _getRemoteFileInfo(fileName) {
Expand Down Expand Up @@ -178,7 +178,7 @@ class DavUploader {
* @param {number} fileId Thunderbird's internal file if
* @param {string} fileName The name in the cloud
* @param {File} fileObject The File object to upload
* @returns {Promise} A Promise that resolves to the http response
* @returns {Promise<Response>} A Promise that resolves to the http response
*/
async _doUpload(fileId, fileName, fileObject) {
// Make sure storageFolder exists. Creation implicitly checks for
Expand Down Expand Up @@ -218,10 +218,10 @@ class DavUploader {
*
* @param {string} path the full file path of the object
* @param {string} [method=GET] the HTTP METHOD to use, default GET
* @param {*} [body] Body of the request, eg. file contents
* @param {*} [abortController] An AbortController to abort the network
* @param {Array} [body] Body of the request, eg. file contents
* @param {Array} [abortController] An AbortController to abort the network
* transaction
* @returns {*} A Promise that resolves to the Response object
* @returns {Promise<Response>} A Promise that resolves to the Response object
*/
async _doDavCall(path, method, body, abortController, additional_headers) {
let url = this._serverurl;
Expand Down
3 changes: 3 additions & 0 deletions src/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */

/* exported encodepath */
/* exported daysFromTodayIso */

/**
* Encode everything that might need encoding in pathnames, including those
* chars encodeURI leaves as is
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"description": "__MSG_extensionDescription__",
"homepage_url": "https://gitlab.com/joendres/filelink-nextcloud",
"author": "Johannes Endres",
"version": "3.4.0",
"version": "3.4.1",
"icons": {
"48": "icon48.png"
},
Expand Down
24 changes: 12 additions & 12 deletions src/prefspane/management.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,47 +10,47 @@ body {

/* show the turning wheel cursor while the dialog is busy */

body.busy * {
.busy * {
cursor: progress;
}

/* Header elements */

#header::after {
content: "";
clear: both;
content: "";
display: table;
}

h2 {
margin: 0;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
margin: 0;
white-space: nowrap;
}

#cloud_info {
float: right;
text-align: right;
margin-left: 8px;
text-align: right;
}

#cloud_info #logo {
#logo {
height: 36px;
}

/* Free space display */

#freespaceGauge {
margin-top: 4px;
display: flex;
white-space: nowrap;
margin-top: 4px;
visibility: hidden;
white-space: nowrap;
}

meter {
width: 100%;
margin-left: .5em;
width: 100%;
}

meter:-moz-meter-optimum::-moz-meter-bar {
Expand Down Expand Up @@ -92,11 +92,11 @@ input[type=number] {
}

.helpbutton p {
visibility: hidden;
position: absolute;
z-index: 1;
width: 50%;
right: 0;
visibility: hidden;
width: 50%;
z-index: 1;
}

.helpbutton:hover p {
Expand Down
2 changes: 1 addition & 1 deletion src/prefspane/management.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ <h2 id="provider-name">*cloud</h2>
<span class="checkbox__label__text" data-message="useDlPassword"></span>
</label>
<label class="input">
<input id="downloadPassword" type="text" disabled class="input__field" value=""" />
<input id="downloadPassword" type="text" disabled class="input__field" value="" />
</label>
</p>

Expand Down
45 changes: 26 additions & 19 deletions src/prefspane/management.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
const accountId = new URL(location.href).searchParams.get("accountId");
const ncc = new CloudConnection(accountId);

const freeSpaceGauge = document.querySelector("#freespaceGauge");
const hiddenVersion = document.querySelector("#versionstring");
const hiddenType = document.querySelector("#cloudtype");
const hiddenProductname = document.querySelector("#productname");
Expand Down Expand Up @@ -60,24 +61,30 @@ const resetButton = document.querySelector("#resetButton");
})();

function fillHeader() {
browser.cloudFile.getAccount(accountId).then(
theAccount => {
// Update the free space gauge
let free = theAccount.spaceRemaining;
const used = theAccount.spaceUsed;
if (free >= 0 && used >= 0) {
const full = (free + used) / (1024.0 * 1024.0 * 1024.0); // Convert bytes to gigabytes
free /= 1024.0 * 1024.0 * 1024.0;
document.querySelector("#freespacelabel").textContent = browser.i18n.getMessage("freespace", [
free > 100 ? free.toFixed() : free.toPrecision(2),
full > 100 ? full.toFixed() : full.toPrecision(2),]);
const meter = document.querySelector("#freespace");
meter.max = full;
meter.value = free;
meter.low = full / 10;
document.querySelector("#freespaceGauge").style.visibility = "visible";
}
});
// Only show gauge if relevant form data match the account data
if (username.value !== ncc.username || serverUrl.value !== ncc.serverUrl) {
freeSpaceGauge.style.visibility = "hidden";
} else {
browser.cloudFile.getAccount(accountId)
.then(theAccount => {
// Update the free space gauge
let free = theAccount.spaceRemaining;
const used = theAccount.spaceUsed;
if (free >= 0 && used >= 0) {
const full = (free + used) / (1024.0 * 1024.0 * 1024.0); // Convert bytes to gigabytes
free /= 1024.0 * 1024.0 * 1024.0;
document.querySelector("#freespacelabel").textContent = browser.i18n.getMessage("freespace", [
free > 100 ? free.toFixed() : free.toPrecision(2),
full > 100 ? full.toFixed() : full.toPrecision(2),]);
const meter = document.querySelector("#freespace");
meter.max = full;
meter.value = free;
meter.low = full / 10;
freeSpaceGauge.style.visibility = "visible";
}
});
}
// Show cloud flavor and version
document.querySelector("#cloud_version").textContent = hiddenVersion.value;
document.querySelector("#service_url").href = serverUrl.value;
if (hiddenProductname.value && hiddenProductname.value !== "undefined") {
Expand Down Expand Up @@ -248,7 +255,7 @@ serverUrl.onchange = async () => {
hiddenVersion.value = ct.versionstring;
hiddenType.value = ct.type;
hiddenProductname.value = ct.productname;
if (ct.type==="Unsupported") {
if (ct.type === "Unsupported") {
popup.warn("unsupported_cloud");
}

Expand Down
Loading

0 comments on commit d36999f

Please sign in to comment.