Coder Social home page Coder Social logo

Comments (1)

blizzz avatar blizzz commented on June 14, 2024

(If I understand it correctly, %n is created by using the full path and stripping the base)

nope, it's more complicated:

protected function replacePlaceholderN(Node $node): string {
$owner = $node->getOwner();
try {
$nodeID = $node->getId();
$storage = $node->getStorage();
} catch (NotFoundException | InvalidPathException $e) {
$context = [
'app' => 'workflow_script',
'exception' => $e,
'node' => $node,
];
$message = 'Could not get if of node {node}';
if (isset($nodeID)) {
$message = 'Could not find storage for file ID {fid}, node: {node}';
$context['fid'] = $nodeID;
}
$this->logger->warning($message, $context);
throw new PlaceholderNotSubstituted('n', $e);
}
if (isset($storage) && $storage->instanceOfStorage(GroupFolderStorage::class)) {
// group folders are always located within $DATADIR/__groupfolders/
$absPath = $storage->getLocalFile($node->getPath());
$pos = strpos($absPath, '/__groupfolders/');
// if the string cannot be found, the fallback is absolute path
// it should never happen #famousLastWords
if ($pos === false) {
$this->logger->warning(
'Groupfolder path does not contain __groupfolders. File ID: {fid}, Node path: {path}, absolute path: {abspath}',
[
'app' => 'workflow_script',
'fid' => $nodeID,
'path' => $node->getPath(),
'abspath' => $absPath,
]
);
}
$ncRelPath = substr($absPath, (int)$pos);
} elseif (isset($storage) && $storage->instanceOfStorage(SharedStorage::class)) {
try {
$folder = $this->rootFolder->getUserFolder($owner->getUID());
} catch (NotPermittedException | NoUserException $e) {
throw new PlaceholderNotSubstituted('n', $e);
}
$nodes = $folder->getById($nodeID);
if (empty($nodes)) {
throw new PlaceholderNotSubstituted('n');
}
$newNode = array_shift($nodes);
$ncRelPath = $newNode->getPath();
} else {
$ncRelPath = $node->getPath();
if (strpos($node->getPath(), $owner->getUID()) !== 0) {
$nodes = $this->rootFolder->getById($nodeID);
foreach ($nodes as $testNode) {
if (strpos($node->getPath(), $owner->getUID()) === 0) {
$ncRelPath = $testNode;
break;
}
}
}
}
$ncRelPath = ltrim($ncRelPath, '/');
return $ncRelPath;
}

%f should give you the absolute path for files available on local storage. Those from external will be copied to a temp directory.

from workflow_script.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.