From what I can see, the DocumentDirectoryPath changes after every TestFlight update. This means that previously downloaded files cannot be accessed by using DocumentDirectoryPath in future builds.
Does this mean that I'd have to cache the first instance of DocumentDirectoryPath being used and always read/write from that?
Also, is this only the behaviour of TestFlight or updates in general?
Update:
So to get around this currently I'll do the following:
AsyncStorage.getItem("folderPath", (err, res) => {
if (!res) {
AsyncStorage.setItem("folderPath", base_dir)
} else if (res !== base_dir) {
console.log("Moving", `${res}/documents`, `${base_dir}/documents`)
FS.moveFile(`${res}/documents`, `${base_dir}/documents`)
.then(() => {
AsyncStorage.setItem("folderPath", base_dir);
});
}
});
This is far from ideal though
Same issue here with apps distributed with Microsoft App Center...
Your workaround does the job!
Thanks!
Yeah, it's pretty crazy but I don't know whether this library could really avoid this issue - a new directory gets created per install
@kyle-ssg I ran into the same issue. Storing the file names and accessing them with a global path function seems to work as file names don't change after app update:
const path = fileName => `${RNFS.DocumentDirectoryPath}/files/${fileName}`;
This looks more related to RN and testflight.
react-native-fs is affected, along with anything using the asyncStorage to store file paths and testflight.
@kyle-ssg Have you tested if this limited to testflight? or do apps updated through the appstore get hit ass well?
I have the same issue, and it is happening with the app store app as well! Using RN 0.59.3
@rreiser-auti.
It's not a bug, it's a feature :-|.
Any new build you make will have a different path. You have to use dynamic paths. As suggested by @anarkafkas:
With Expo I was able to compose my path using FileSystem.cacheDirectory + fileName. I am sure you will find a way using what's available in your environment.
I would close this issue btw.
Most helpful comment
@kyle-ssg I ran into the same issue. Storing the file names and accessing them with a global path function seems to work as file names don't change after app update: