You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
604 B
JavaScript
26 lines
604 B
JavaScript
"use strict";
|
|
|
|
const Promise = require("bluebird");
|
|
const memoizee = require("memoizee");
|
|
|
|
const lvm = require("../../../packages/exec-lvm");
|
|
const All = require("../../../packages/graphql-interface/symbols/all");
|
|
|
|
module.exports = function () {
|
|
let getPhysicalVolumesOnce = memoizee(lvm.getPhysicalVolumes);
|
|
|
|
return function (paths) {
|
|
return Promise.try(() => {
|
|
return getPhysicalVolumesOnce();
|
|
}).then((volumes) => {
|
|
return paths.map((path) => {
|
|
if (path === All) {
|
|
return volumes;
|
|
} else {
|
|
return volumes.find((device) => device.path === path);
|
|
}
|
|
});
|
|
});
|
|
};
|
|
};
|