Diffusion and photoswitching in nanoporous thin films of metal-organic frameworks