Skip to content

SMB/CIFS share breaks when it contains a symlink entry that can't be accessed #15876

Description

@rik26

Related to :
#7332
#7556

Having a symlink on a smb share gave an unhandled exception : ForbiddenException in /apps/files_external/lib/Lib/Storage/SMB.php, private function shareMTime()

I resolved the bug with the following code. I'm unable to create a PR, i don't understand how it works.

In
/apps/files_external/lib/Lib/Storage/SMB.php :

/**
         * get the best guess for the modification time of the share
         *
         * @return int
         */
        private function shareMTime() {
                $highestMTime = 0;
                $files = $this->share->dir($this->root);
                foreach ($files as $fileInfo) {
                        try {
                                if ($fileInfo->getMTime() > $highestMTime) {
                                        $highestMTime = $fileInfo->getMTime();
                                }
                        } catch (NotFoundException $e) {
                                // Ignore this, can happen on unavailable DFS shares
 -                        }
 +                       } catch (ForbiddenException $e) {
 +                               // Ignore this too : symlink
 +                       }
                }
                return $highestMTime;
        }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    0. Needs triagePending check for reproducibility or if it fits our roadmapbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions