2525 */ 
2626namespace  OCA \DAV \Upload ;
2727
28- use  OC \Files \Filesystem ;
2928use  OC \Files \View ;
3029use  OCA \DAV \Connector \Sabre \Directory ;
3130use  Sabre \DAV \Exception \Forbidden ;
@@ -84,13 +83,24 @@ public function getLastModified() {
8483		return  $ this impl ()->getLastModified ();
8584	}
8685
87- 	/** 
88- 	 * @return Directory 
89- 	 */ 
90- 	private  function  impl () {
91- 		$ view$ this getView ();
92- 		$ rootInfo$ viewgetFileInfo ('' );
93- 		return  new  Directory ($ view$ rootInfo
86+ 	private  function  getUploadFolder (): Folder 
87+ 		if  ($ this uploadFolder  === null ) {
88+ 			$ user$ this userSession ->getUser ();
89+ 			if  (!$ user
90+ 				throw  new  Forbidden ('Not logged in ' );
91+ 			}
92+ 			$ path'/ '  . $ usergetUID () . '/uploads ' ;
93+ 			try  {
94+ 				$ folder$ this rootFolder ->get ($ path
95+ 				if  (!$ folderinstanceof  Folder) {
96+ 					throw  new  \Exception ('Upload folder is a file ' );
97+ 				}
98+ 				$ this uploadFolder  = $ folder
99+ 			} catch  (NotFoundException $ e
100+ 				$ this uploadFolder  = $ this rootFolder ->newFolder ($ path
101+ 			}
102+ 		}
103+ 		return  $ this uploadFolder ;
94104	}
95105
96106	private  function  getView () {
@@ -104,8 +114,6 @@ private function getView() {
104114	}
105115
106116	private  function  getStorage () {
107- 		$ view$ this getView ();
108- 		$ storage$ viewgetFileInfo ('' )->getStorage ();
109- 		return  $ storage
117+ 		return  $ this getUploadFolder ()->getStorage ();
110118	}
111119}
0 commit comments